I am working on application which needs to load bmp 16bit(5-6-5) images to QPixmap. Is there any way in Qt of doing this directly like for 24bit bmp's?
I tried to convert all images to 24bit version and there were no problems with loading them. Unfortunately I really need to work with 16bit.
I tried also the following code, but without success. However I could load 16bit (1-5-5-5) version of my bmp.
QImage img = QImage(300, 300, QImage::Format_RGB16);
img.loadFromData(imgArray);
ui->test->setPixmap(QPixmap::fromImage(img));
It seems to work pretty well for me using the QImage constructor:
Basically, the use would be:
and the RGB16 format should be picked up by the constructor on its own from the file header.
EDIT:
The file you posted seems to be using a header type that is not supported by Qt. It is an undocumented header with size 56 called
BITMAPV3INFOHEADER
, which Wikipedia explains as:It seems to be a quite special header type that is not supported by many libraries. However, gimp or ImageMagic can load it and convert it, so I suggest that you converted your files to another BMP file with RGB565 encoding that uses a more standard header. Then, the above code will work for you.