Jump to content
Site Stability Read more... ×
  • Advertisement
Sign in to follow this  

Reversing D3DCOLOR

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

Hi guys,


When defining a colour like


D3DCOLOR c_black=D3DCOLOR_ARGB(255,0,0,0);


Is there a way to get read the ARGB components back from the variable later?


Something like c_black.a, c_black.r, etc..?


Thanks in advance :)

Share this post

Link to post
Share on other sites
If you look at the definition of that macro:
#define D3DCOLOR_ARGB(a,r,g,b) \
You can reverse it like this:
D3DCOLOR color = ...;
DWORD r = (color >> 16)&0xff;
DWORD g = (color >>  8)&0xff;
DWORD b = (color      )&0xff;
DWORD a = (color >> 24)&0xff;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!