#### Archived

This topic is now archived and is closed to further replies.

# How to convert bitmap.....

This topic is 6088 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How to convert bitmap(*.bmp) 16bit to 24 bit using c/c++. Help me! Thx.

##### Share on other sites
It depends what pixel format you have for 16 bit. If you have 5-6-5, then you use a different method than 5-5-5. (red-green-blue bits)

If you have 5-5-5, something like this will work:
red = (color16 >> 10) & 0x1F;
green = (color16 >> 5) & 0x1F;
blue = color 16 & 0x1F;

color24 = (red << 19) | (green << 11) | (blue << 3);

I believe that is about right. You basically want to take the five bits of each color component and put it into the highest five bits of your 24 bit color components.

##### Share on other sites
You may wish to replace the upper bits of the 5-bit/6-bit value into the lower bits of the 8-bit value. Otherwise you are sitting them to 0 which will slighly darken brighter colors.

i.e., the birghtest red/green/blue/white in 5-bit color is 11111, which when conveted to 8-bits is 11111000, which is darker than 11111111 !!

-Matt P
Developer AoE/AoK/???

• 11
• 20
• 12
• 10
• 34
• ### Forum Statistics

• Total Topics
631399
• Total Posts
2999854
×