Extracting the A,R,G and B from a D3DCOLOR
Given a D3DCOLOR, how would I go about extracting the Alpha, Red, Green and Blue components into seperate ints?
Well, looking at MSDN, it says that D3DCOLOR is defined as:
So, you should be able to extract the info as this:
... 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]
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]
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]
[edited by - PlayGGY on December 13, 2003 12:30:38 AM]
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.
You could also use the GetRValue(), GetBValue(), and GetGValue() win32 functions. Check it out in msdn.
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.
You would think that they would write those kind of functions down in the D3DCOLOR-document.
quote:Original post by Namethatnobodyelsetookquote: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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement