This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[Image processing] the header size of bmp files and reading from a bmp

Hi,

I am converting 24 bit bmp files to rgb888 format. So far I didn't have any problem. But today, while I was processing character set images, I noticed that my converter didn't work right for images with width size not aligned to 8.

For example, I am processing the character "B". It's width is 7. While I get incorrect results for this width, if I resize it to 8 pixel width, I can convert it correctly.

Since I don't have any problem in the converter code, I suspect if a header size of an image shall be not constant, especially for the small images such as 7*12.

Also another thing I suspect is that I am reading the binary values using fread, by the size of an char. However, assuming a binary image file (bmp for example) is stream of pixels, it shall not differ if I read by a size that is aligned by 8 or not.

The funny thing is that I can resize the characters lesser than 8 pixel width to 8 pixel, but there are some characters, like "A" which is larger than 8 pixel.

I wonder if anyone has any idea about this situation. Thanks.

Erman

  • How are you converting 24-bit BMP to RGB888 (e.g. via some software utility)?

    When you mention width, are you referring to number of pixels (e.g. character "B" is 7 pixels wide) or byte width?  I am guessing the former.  Also, does this issue relate to the hardware in any way or is it strictly a software domain question?

    From a hardware point of view, each pixel (24-bits) is 3 bytes, so image must be multiple of 3 bytes; however, there is another hardware restriction on our DaVinci processor's (which one are you using by the way?) video processing hardware in that they read and write (via DMA) 32-bytes of data at time from DDR2.

    I am not sure I understand the issue above 100%, so if the information provided here is not helpful, please feel free to elaborate.

  • I think the problem you are seeing is just an artifact of the way that the BMP format is storing the image data, it looks like it will put in padding to ensure that each line starts on a 32 bit boundary, I imagine if your converter takes that into account than images that do not align by default should be convertable. The Wikipedia BMP article looks to do a good job of explaining the format and showing an example of how it ends up being laid out, hopefully this can help show why you are seeing this issue.

  • Hi Guys

    Could anyone help me finding an BMP(1024x768) to RGB888 image converter ?

    Thanks

  • Mishra,

    Check the header of the BMP to find out what is the color format first. It might already be RGB888. If so, just strip off the 54 bytes header. That's it.