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
@ -59,16 +59,16 @@ class ImageExporter(Exporter):
|
|||||||
self.fileSaveDialog(filter=filter)
|
self.fileSaveDialog(filter=filter)
|
||||||
return
|
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()
|
sourceRect = self.getSourceRect()
|
||||||
|
|
||||||
|
bg = np.empty((h, w, 4), dtype=np.ubyte)
|
||||||
#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)
|
|
||||||
color = self.params['background']
|
color = self.params['background']
|
||||||
bg[:,:,0] = color.blue()
|
bg[:,:,0] = color.blue()
|
||||||
bg[:,:,1] = color.green()
|
bg[:,:,1] = color.green()
|
||||||
|
Loading…
Reference in New Issue
Block a user