0

I wrote a program which loads a bitmap file (only) to a window, and it's works fine for any file with .bmp extansion. But I faced with the next problem when I was making a testing. I took a file with .jpg extansion, opened it in Paint and then saved it as a BMP file. When I was starting a test with this new file, my program loaded a black window.

I made a debug and find out that biColorUsed field of BITMAPINFOHEADER structure is zero. According to doc, this means that

the bitmap uses the maximum number of colors corresponding to the value of the biBitCount member for the compression mode specified by biCompression.

biCompression field is also zero which means that file is uncompressed.

biBitCount is equal to 24 which means (according to same docs) that

The bmiColors color table is used for optimizing colors used on palette-based devices, and must contain the number of entries specified by the biClrUsed member of the BITMAPINFOHEADER

It couldn't be specified because biClrUsed is zero.

So, the question is, is BMP file created by a conversion of JPG file using Paint realy a BMP file?

P. S. I use CreateDIBitmap function in my program. When I load the same BMP file using LoadImage, it works fine. Any other fields of structures BITMAPFILEHEADER, BITMAPINFOHEADER is loaded correctly. That's why I think that I properly load data from BMP file. I could upload my project on GoogleDrive and then share it if this would be needed.

  • what are the first four bytes of the image file? – meklarian Feb 07 '14 at 23:46
  • @meklarian first two bytes is a `bfType` field of `BITMAPFILEHEADER` which is equal to 19778 which is "BM". Second field is a `bfSize` which is equal to 1537078. It's first byte is 36 in hexodemical, second one is 74. I guess I didn't understand your question correctly) –  Feb 08 '14 at 00:15
  • @meklarian The first four are 42, 4d, ffffffcc, ffffffcc. –  Feb 08 '14 at 00:24
  • 1
    merely curious whether the fourCC of the file (see: http://en.wikipedia.org/wiki/FourCC ) corresponds to one of the well-known BMP markers. if the first three bytes happened to correspond to 'JPG' or something else, then that would explain your issue right-away. – meklarian Feb 08 '14 at 00:26
  • @meklarian I didn't know about fourCC, thanks) –  Feb 08 '14 at 00:28
  • 1
    a full list is available here: http://www.fourcc.org/ , you should see a match in here that may explain what kind of output you are getting: http://www.fourcc.org/rgb.php – meklarian Feb 08 '14 at 00:29

0 Answers0