Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


32 Bit Macro *NEED HELP*


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 acw83   Members   -  Reputation: 174

Like
Likes
Like

Posted 15 December 1999 - 03:25 PM

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!


Sponsor:

#2 joeG   Members   -  Reputation: 172

Like
Likes
Like

Posted 14 December 1999 - 04:26 PM

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


#3 alexmoura   Members   -  Reputation: 450

Like
Likes
Like

Posted 15 December 1999 - 01:09 AM

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

#4 acw83   Members   -  Reputation: 174

Like
Likes
Like

Posted 15 December 1999 - 08:16 AM

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!

#5 logistix   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 December 1999 - 03:25 PM

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.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS