• Advertisement

Archived

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

Extracting the A,R,G and B from a D3DCOLOR

This topic is 5184 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

Given a D3DCOLOR, how would I go about extracting the Alpha, Red, Green and Blue components into seperate ints?

Share this post


Link to post
Share on other sites
Advertisement
Well, looking at MSDN, it says that D3DCOLOR is defined as:
typedef DWORD D3DCOLOR  

So, you should be able to extract the info as this:
a = (myColor >> 24) & 0xFF;
r = (myColor >> 16) & 0xFF;
g = (myColor >> 8) & 0xFF;
b = myColor & 0xFF;

... or the other way around (change the order of a r g b.. dunno about it)

edit: added alpha

[edited by - Jolle on December 13, 2003 6:41:39 AM]

Share this post


Link to post
Share on other sites
Yep, your right, the order is 0xAARRGGBB, so use a bitwise AND '&&'. EDIT: I mean '&'... woops...

[edited by - PlayGGY on December 13, 2003 12:30:38 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by PlayGGY
Yep, your right, the order is 0xAARRGGBB, so use a bitwise AND ''&&''.


He did use a bitwise and. You''re using a logical and, and calling it bitwise. Please drink more coffee.

Share this post


Link to post
Share on other sites
You could also use the GetRValue(), GetBValue(), and GetGValue() win32 functions. Check it out in msdn.

Share this post


Link to post
Share on other sites
Yeah, but they doesn''t seem to have an GetAValue() :/
You would think that they would write those kind of functions down in the D3DCOLOR-document.

Share this post


Link to post
Share on other sites
quote:
Original post by Namethatnobodyelsetook
quote:
Original post by PlayGGY
Yep, your right, the order is 0xAARRGGBB, so use a bitwise AND ''&&''.


He did use a bitwise and. You''re using a logical and, and calling it bitwise. Please drink more coffee.


*cries* Your right... ''&''. Should have caught that.

Share this post


Link to post
Share on other sites

  • Advertisement