I am trying to load an image that is given to me as a BITMAPINFO* and a uchar array.
The documentation states that it is a standard Microsoft device independent bitmap (DIB) with 8-bit pixels and a 256-entry color table.
I am curently able to open this image through:
BITMAPINFO* bmih = givenBITMAPINFO;
uchar* data = givenData;
QImage img = QImage(data, bmih->biWidth, bmih->biHeight, QImage::Format_Grayscale8);
But I have two problems with that:
the image is in
QImage::Format_Grayscale8when the documentation states an 8-bit pixels and a 256-entry color table;the image is upside down and mirrored. This come from the way the bitmap data is stored in Win32.
Anyone knows how I can load properly this image?
BITMAPINFOHEADERin a standard bitmap file. Unless the pointer you have points at aBITMAPINFOHEADERfollowed by the color palette there is no way for you to reconcile the color information. - IInspectableBITMAPINFO. But then the image is backward, what would be the most efficient way to load it streight? - firehelmQImagec'tors are capable of flipping the image, so you would have to apply QImage::mirrored as a second step. Also note that there is QImage::setColorTable. In combination with a QImage::Format_Indexed8 image format you should be able to construct your image. - IInspectable