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:
parent
584c4516f0
commit
3edbef6c57
@ -58,17 +58,17 @@ class ImageExporter(Exporter):
|
||||
filter.insert(0, p)
|
||||
self.fileSaveDialog(filter=filter)
|
||||
return
|
||||
|
||||
targetRect = QtCore.QRect(0, 0, self.params['width'], self.params['height'])
|
||||
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']
|
||||
|
||||
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))
|
||||
bg = np.empty((self.params['height'], self.params['width'], 4), dtype=np.ubyte)
|
||||
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()
|
||||
|
||||
bg = np.empty((h, w, 4), dtype=np.ubyte)
|
||||
color = self.params['background']
|
||||
bg[:,:,0] = color.blue()
|
||||
bg[:,:,1] = color.green()
|
||||
|
Loading…
Reference in New Issue
Block a user