Archived

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

color conversion

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

Recommended Posts

Hi I need mathematical solution for converting RGB to bits and bits to RGB for use of direct draw. any tutorials for this? i allready have RGB32 RGB16 RGB15 and the windows RGB defines so if u have any else conversion defines please share them. Got these whit one book: // this builds a 16 bit color value in 5.5.5 format (1-bit alpha mode) #define _RGB16BIT555(r,g,b) ((b & 31) + ((g & 31) << 5) + ((r & 31) << 10)) // this builds a 16 bit color value in 5.6.5 format (green dominate mode) #define _RGB16BIT565(r,g,b) ((b & 31) + ((g & 63) << 6) + ((r & 31) << 11)) // this build a 32 bit color value #define _RGB32BIT(a,r,g,b) ((b) + ((g) << 8) + ((r) << 16) + ((a) << 24))

Share on other sites
quote:
Original post by Craazer
// this builds a 16 bit color value in 5.5.5 format (1-bit alpha mode)
#define _RGB16BIT555(r,g,b) ((b & 31) + ((g & 31) << 5) + ((r & 31) << 10))

// this builds a 16 bit color value in 5.6.5 format (green dominate mode)
#define _RGB16BIT565(r,g,b) ((b & 31) + ((g & 63) << 6) + ((r & 31) << 11))

Umm, I think those won''t work. You need to take the most significant bits.

- JQ
Full Speed Games. Period.

Share on other sites

Thanks for pointing that thread.

1. 1
2. 2
Rutin
17
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• Forum Statistics

• Total Topics
633735
• Total Posts
3013596
×

Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!