RawImageWidget uses imageAxisOrder config option

This commit is contained in:
Ogi Moore 2021-02-16 22:18:17 -08:00
parent acd172eb13
commit 0b26ef3644

View File

@ -43,6 +43,8 @@ class RawImageWidget(QtGui.QWidget):
img must be ndarray of shape (x,y), (x,y,3), or (x,y,4). img must be ndarray of shape (x,y), (x,y,3), or (x,y,4).
Extra arguments are sent to functions.makeARGB Extra arguments are sent to functions.makeARGB
""" """
if getConfigOption('imageAxisOrder') == 'row-major':
img = img.transpose((1, 0, 2))
self.opts = (img, args, kargs) self.opts = (img, args, kargs)
self.image = None self.image = None
self.update() self.update()
@ -79,7 +81,7 @@ if HAVE_OPENGL:
class RawImageGLWidget(QtWidgets.QOpenGLWidget): class RawImageGLWidget(QtWidgets.QOpenGLWidget):
""" """
Similar to RawImageWidget, but uses a GL widget to do all drawing. Similar to RawImageWidget, but uses a GL widget to do all drawing.
Perfomance varies between platforms; see examples/VideoSpeedTest for benchmarking. Performance varies between platforms; see examples/VideoSpeedTest for benchmarking.
Checks if setConfigOptions(imageAxisOrder='row-major') was set. Checks if setConfigOptions(imageAxisOrder='row-major') was set.
""" """
@ -91,7 +93,6 @@ if HAVE_OPENGL:
self.uploaded = False self.uploaded = False
self.smooth = False self.smooth = False
self.opts = None self.opts = None
self.row_major = getConfigOption('imageAxisOrder') == 'row-major'
def setImage(self, img, *args, **kargs): def setImage(self, img, *args, **kargs):
""" """
@ -118,13 +119,12 @@ if HAVE_OPENGL:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER)
# glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER) # glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER)
if getConfigOption('imageAxisOrder') == 'row-major':
if self.row_major:
image = self.image image = self.image
else: else:
image = self.image.transpose((1, 0, 2)) image = self.image.transpose((1, 0, 2))
# ## Test texture dimensions first ## Test texture dimensions first
# shape = self.image.shape # shape = self.image.shape
# glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA, shape[0], shape[1], 0, GL_RGBA, GL_UNSIGNED_BYTE, None) # glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA, shape[0], shape[1], 0, GL_RGBA, GL_UNSIGNED_BYTE, None)
# if glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH) == 0: # if glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH) == 0: