Types of BMP images
-
Thursday, August 09, 2012 10:32 AM
Hi,
I am working on image conversion mostly BMP to 16 bit,8 bit, and monochrome.
I just converted a BMP image(24 bit) to 16 bit image using following code
#define RGB16(red, green, blue) (((red >> 3) << 11) | ((green >> 2) << 5) | (blue >> 3))
for( int y=0; y<infoheader.biHeight; ++y)
{
for( int x=0; x<infoheader.biWidth; ++x)
{
fread(&blue, sizeof(BYTE), 1, bitmapFile);
fread(&green, sizeof(BYTE), 1, bitmapFile);
fread(&red, sizeof(BYTE), 1,bitmapFile);
bitmapData[y*infoheader.biWidth + x] = RGB16(red, green, blue);
}
}But the image i got in 16 bit differs from the same image converted to 16-color bit obtained using MS paint?????Why this is happening????
Also please explain me how to convert 24 bit BMP image to monochrome???????
Gopinath.S
All Replies
-
Thursday, August 09, 2012 10:39 AM
A 16bit image has in total the possibility on using 65536 colors. A color value is represented by two bytes. A 16 color image has only 16 colors in total. A color value is repesented by 4 bits. Two pixels are stored in one byte. Therefore the images are not (binary) identical, even if the images loors the same in a picture viewer.
Here you can read about the different BMP image "sub"-types:
http://en.wikipedia.org/wiki/BMP_file_format
-- ---
Addition:
The Bitmaps with lower color number of colors also works with color tables. A pixel value does not represent the real color value, it only represents a table index in the color table.
- Edited by BordonMicrosoft Community Contributor Thursday, August 09, 2012 10:43 AM
- Marked As Answer by Damon ZhengMicrosoft Contingent Staff, Moderator Wednesday, August 29, 2012 7:43 AM
-
Thursday, August 09, 2012 10:47 AM
Hi,
Will you suggest me how can i convert 24 bit BMP image to Monochrome(1 bit )BMP image
Gopinath.S
-
Thursday, August 09, 2012 12:27 PM
In a monochrome bitmap 8 pixels are stored in a byte. To find out how to convert such bitmaps from i.e. 24bit to 1 bit I'd suggest checking the Bitmap file specifications thar running around in the internet. The Wikipedia link should help you to learn how the specific bitmpa types are organized and stored.
The difficuilt part on converting is that you still have a remeining picture information in your converted bitmap. There are algorithms out, but I can not actually point them out.
Here a few information about the windows bmp file format:
http://www.mediatel.lu/workshop/graphic/2D_fileformat/h_bmp.html
http://www.dragonwins.com/domains/getteched/bmp/bmpfileformat.htm
Also this article is very nice and explains how bitmaps work that use color tables:
- Edited by BordonMicrosoft Community Contributor Thursday, August 09, 2012 12:32 PM
- Marked As Answer by Gopinath.S Saturday, January 19, 2013 10:10 AM

