QImage Class, loading an image results in different behaviour between debug and release
-
I have found the root of my image display problem after some investigations but I still don't understand if this is actually a bug.
My program is working fine in release but not really in debug sessions.Here is the part. I load a 2048x2048 grayscale 8bits bmp image this way:
QImage image(":/v3_res.bmp");
Then if I verify the image format:
qDebug() << "image format is " << image.format();
qDebug() << "image size is " << image.byteCount();Output from release:
image format is 3
image size is 4194304Output from debug:
image format is 4
image size is 16777216While this is actually the same image, the pixel format is not the same.
Tried this:
QImage image(2048,2048,QImage::Format_Indexed8);
image.load(":/v3_res.bmp", "BMP");
But it doesn't change format during debug.Also tried this:
image = image.convertToFormat(QImage::Format_Indexed8);
which show an image but looks kinda strange because you see it was not read in the correct format first.Image metadata looks correct (Windows report 8 Bits depth) and file size is 4'195'382 bytes
So I have 2 questions now:
Is this a bug?
Is there a way to force the format during the creation of the QImage with a filename?Thank you for your answers
-
I upload it here
https://drive.google.com/file/d/0B8NvEIhEx_TfQTBVc3JYb3NjMHM/view?usp=sharing
File was found in png on internet, converted to 256-grayscale and saved to bitmap using XnViewI'm using
Qt 5.8.0 MinGW 32bit (mingw53_32)
MinGW 5.3.0 32bit
Windows 10 Pro 64 (v1703) -
Just to update the issue, I tried the minimal code to load this image and it works now correctly everytime in debug too.. format 3 (QImage::Format_Indexed8) is reported for both.
The issue is probably coming from somewhere else but it will be very difficult to track it down now...
The code is exactly:
"
QImage image(":/v3_res.bmp");
qDebug() << "image format is " << image.format();
qDebug() << "image size is " << image.byteCount();
"
And I don't understand how it may be related to anything else in my software.Still looking for a way to force this in a manual way for the moment.
-