Hi everyone,
I'm stuck with an issue that looks quite stupid to me. Nonetheless I don't seem to be smart enough to solve it... :/
What I'm trying to do is simply to read the RGB values of a pixel contained in a QImage. To do so I'm using the following instructions:
X = rand() % originalImage.width();
Y = rand() % originalImage.height();
QRgb tempColorRgb
= originalImage.
pixel(QPoint(X,Y
));
QColor tempColor
(tempColorRgb
);
printf("RGB components of the pixel selected: %d %d %d\n", tempColor.red(), tempColor.green(), tempColor.blue());
X = rand() % originalImage.width();
Y = rand() % originalImage.height();
QRgb tempColorRgb = originalImage.pixel(QPoint(X,Y));
QColor tempColor(tempColorRgb);
printf("RGB components of the pixel selected: %d %d %d\n", tempColor.red(), tempColor.green(), tempColor.blue());
To copy to clipboard, switch view to plain text mode
What I get is that all the values look the same, whatever pixel I select. For example:
RGB components of the pixel selected: 0 0 0
RGB components of the pixel selected: 241 241 241
RGB components of the pixel selected: 27 27 27
OriginalImage is a QImage declared and initialised elsewhere in the code. It actually contains a jpeg picture loaded from the disk. I'm confident there's nothing wrong with it, as it is visible (it's displayed on my GUI) and accessible from the code above (I tried to save it with an instruction in the portion of the code below and everything went fine).
Am I doing something obviously and terribly wrong which I can't notice?
Bookmarks