ROI.py::renderShapeMask : fix little-endian assumption
This commit is contained in:
parent
afe47def28
commit
98a020d1bb
|
@ -23,6 +23,7 @@ from .GraphicsObject import GraphicsObject
|
||||||
from .UIGraphicsItem import UIGraphicsItem
|
from .UIGraphicsItem import UIGraphicsItem
|
||||||
from .. import getConfigOption
|
from .. import getConfigOption
|
||||||
import warnings
|
import warnings
|
||||||
|
import sys
|
||||||
|
|
||||||
translate = QtCore.QCoreApplication.translate
|
translate = QtCore.QCoreApplication.translate
|
||||||
|
|
||||||
|
@ -1287,7 +1288,7 @@ class ROI(GraphicsObject):
|
||||||
return np.empty((width, height), dtype=float)
|
return np.empty((width, height), dtype=float)
|
||||||
|
|
||||||
im = QtGui.QImage(width, height, QtGui.QImage.Format.Format_ARGB32)
|
im = QtGui.QImage(width, height, QtGui.QImage.Format.Format_ARGB32)
|
||||||
im.fill(0x0)
|
im.fill(QtCore.Qt.GlobalColor.transparent)
|
||||||
p = QtGui.QPainter(im)
|
p = QtGui.QPainter(im)
|
||||||
p.setPen(fn.mkPen(None))
|
p.setPen(fn.mkPen(None))
|
||||||
p.setBrush(fn.mkBrush('w'))
|
p.setBrush(fn.mkBrush('w'))
|
||||||
|
@ -1297,8 +1298,9 @@ class ROI(GraphicsObject):
|
||||||
p.translate(-bounds.topLeft())
|
p.translate(-bounds.topLeft())
|
||||||
p.drawPath(shape)
|
p.drawPath(shape)
|
||||||
p.end()
|
p.end()
|
||||||
mask = fn.imageToArray(im, transpose=True)[:,:,0].astype(float) / 255.
|
cidx = 0 if sys.byteorder == 'little' else 3
|
||||||
return mask
|
mask = fn.qimage_to_ndarray(im)[...,cidx].T
|
||||||
|
return mask.astype(float) / 255
|
||||||
|
|
||||||
def getGlobalTransform(self, relativeTo=None):
|
def getGlobalTransform(self, relativeTo=None):
|
||||||
"""Return global transformation (rotation angle+translation) required to move
|
"""Return global transformation (rotation angle+translation) required to move
|
||||||
|
|
Loading…
Reference in New Issue
Block a user