Archived

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

32 Bit Macro *NEED HELP*

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites