Ensure exported images use integer dimensions.

It seems that the parameter tree doesn't enforce the int type very
strongly.

Also, use some local variables more often.
This commit is contained in:
Elliott Sales de Andrade 2016-07-09 20:25:52 -04:00
parent 584c4516f0
commit 3edbef6c57

View File

@ -59,16 +59,16 @@ class ImageExporter(Exporter):
self.fileSaveDialog(filter=filter)
return
targetRect = QtCore.QRect(0, 0, self.params['width'], self.params['height'])
w = int(self.params['width'])
h = int(self.params['height'])
if w == 0 or h == 0:
raise Exception("Cannot export image with size=0 (requested "
"export size is %dx%d)" % (w, h))
targetRect = QtCore.QRect(0, 0, w, h)
sourceRect = self.getSourceRect()
#self.png = QtGui.QImage(targetRect.size(), QtGui.QImage.Format_ARGB32)
#self.png.fill(pyqtgraph.mkColor(self.params['background']))
w, h = self.params['width'], self.params['height']
if w == 0 or h == 0:
raise Exception("Cannot export image with size=0 (requested export size is %dx%d)" % (w,h))
bg = np.empty((self.params['height'], self.params['width'], 4), dtype=np.ubyte)
bg = np.empty((h, w, 4), dtype=np.ubyte)
color = self.params['background']
bg[:,:,0] = color.blue()
bg[:,:,1] = color.green()