Mirror image to align QImage and OpenGL texture coordinates#151
Merged
Conversation
ThomasKroes
approved these changes
Mar 3, 2026
Contributor
Author
|
Just for sake of reproducibility, the code to generate the test images: import numpy as np
from PIL import Image
size = 100
# Image 1: x-gradient (columns 0-99, same across all rows)
# Flip vertically so (0,0) is bottom-left
x_array = np.tile(np.arange(size, dtype=np.float32), (size, 1))
x_array = np.flipud(x_array)
# Image 2: y-gradient (rows 0-99, constant across each row)
# y goes 0 (bottom) to 99 (top)
y_values = np.arange(size, dtype=np.float32)
y_array = np.tile(y_values, (size, 1)).T
y_array = np.flipud(y_array)
Image.fromarray(x_array, mode='F').save('./1.tiff')
Image.fromarray(y_array, mode='F').save('./0.tiff') |
alxvth
added a commit
that referenced
this pull request
Mar 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
ImageProp::setColorMapImagewe usetexture.reset(new QOpenGLTexture(colorMapImage));Qt's docs on QOpenGLTexture suggest:
QOpenGLTexture *texture = new QOpenGLTexture(QImage(fileName).flipped());Currently this yields a different re-coloring in the ImageViewer vs the Scatterplot for the same data:

The data here is a 2D image where each pixel value is its coordinates, i.e. at (x: 0, y: 0) the value is (1: 0, 2: 0) and at (x: 25, y: 50) the value is (1: 25, 2: 50)

When mirroring the texture image we get consistent behavior:
In the scatterplot we use
Texture2D::loadFromImagefrom the core (Texture.h) via the PointRenderer.There we just use
(QRgb*)image.bits()to point to the color values instead of converting a QImage to QOpenGLTexture, which appears to behave differently.