I'm trying to understand why the code below changes the QImage in Qt. It's not meant to do anything (yet), it's just for testing. When I run the code on an image with alpha, the alpha channel is lost and replaced by a black background.
QImage image;
image.load("image.png");
for (int y = 0; y < image.height(); y++) {
for (int x = 0; x < image.height(); x++) {
QColor c = QColor::fromRgba(image.pixel(x, y));
c.setHsv(c.hue(), c.saturation(), c.value());
image.setPixel(x, y, c.rgba());
}
}
Here is the result when I comment out the line image.setPixel(...)
:
And here is the result with the image.setPixel(...)
line:
I would expect my code to do no change on the image. Any idea why it's doing this?