🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

32 Bit Macro *NEED HELP*

Started by
3 comments, last by acw83 24 years, 6 months ago
Two things,
You'll first have to decide on how many bits each channel gets in 32 bits (last I checked 3 does not divide into 32 evenly. You could also tack an alpha channel on the end if you're using 24 bits to begin with). Second you'll then have to scale each channel into however many bits you allocated for it. I don't think ANDing each channel with 0xF0 will do that, though.

JoeG

joeG
Advertisement
It should be something like that. RGB 32 bit are usually 8 bits unused or alpha channel, 8 bits red, 8bit green,and 8 bit blue (sometimes the alpha channel goes to that last 8 bits RGBA instead of ARGB) So for ARGB(or XRGB) the macro is allmost the one you posted, but with the shift switched for the red and blue
I am using OpenPTC if that helps any, I still can't plot a pixel of the proper color in 32 bit form. How can I find out it my hardware uses te RGBA or ARGB form? I can achieve the most splendid shades of white and grey, but no color!
At the risk of defacing my good name: What the hell is the macro to convert my 3 rgb's into an 32 bit format??? Something like #define rgb32(r,g,b) ((r&255) + (g&255<<8) + (b&255<<16))

Thanks!

Since everything is byte-aligned on 24 or 32 bit color, you don't really need to shift bits, it's probably quicker( I think ) to use an inline function, something like:

inline void setColor(BYTE* location, BYTE red, BYTE green, BYTE blue, BYTE alpha){    *(location) = red;    *(location + 1) = green;    *(location + 2) = blue;    *(location + 3) = alpha;}

or

inline void setColor(BYTE* location, BYTE red, BYTE green, BYTE blue, BYTE alpha){    *(location++) = red;    *(location++) = green;    *(location++) = blue;    *(location) = alpha;}

and you can move the r, g, b, and a assignments as necessary.

As far as OpenPTC, I can't help you. Sorry.

-the logistical one-http://members.bellatlantic.net/~olsongt

This topic is closed to new replies.

Advertisement