Jump to content
  • Advertisement
Sign in to follow this  
spiffycrony

Basic question : Directx Hexadecimal color codes

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

I am trying to understand the hexadecimal color codes. My understanding is that it stands for RGB(2 Bytes each). So the hexadecimal code should be(I know this is not correct) RED - &HFF0000 GREEN - &H00FF00 BLUE - &H0000FF But it works only when the code is as follows RED = &HFF0000 GREEN = &H1FF00 BLUE = &H1FF How does the above code is formed. What does the 1 indicate in green & blue?

Share this post


Link to post
Share on other sites
Advertisement
I work with DirectX everyday (Not managed) and I have to say I have no idea what codes you are talking about :)

Share this post


Link to post
Share on other sites
Sorry its not actual code.

It has to be

Const RED as long = &HFF0000

in vb.

Anyway I am interested in the hexadecimal(ARGB) colour code. Any help?

Share this post


Link to post
Share on other sites
The color is a hex DWORD (unsigned long, 4 bytes). It takes two hex digits to make a byte, so each color is only 1 byte, not two. You've got the right idea for the masks.

0xFF000000 = alpha mask
0x00FF0000 = red mask
0x0000FF00 = green mask
0x000000FF = blue mask

I can only guess that VB has some silly limits on hex numbers, much like early assemblers. The value probably has to start with a decimal numeric digit... ie: 0-9. It would probably work as &H0FF00 and &H0FF, though I can't imagine how it likes the red mask. It made sense back for the assemblers, as the "hex" notation was a postfix ie: 0FF00h, and it needed the 0 to know it was parsing a number. Have a hex prefix then still needing a decimal digit before any hex ones is just baffling, but I can't imagine any other way to interpret what you're seeing.

Share this post


Link to post
Share on other sites
I'm a little rusty on my VB6 - been a good couple of years since I did any work with it [smile]

Anyway, IIRC, you can put an additional '&' at the end of the hex constant to preserve the full 32bit width - otherwise VB does some crazy stuff with truncating the values. You also have to be a bit careful with the signed bit iirc.

I'm pretty sure one of the older SDK's that supported VB6 had implementations of the D3DCOLOR_XRGB() and D3DCOLOR_ARGB() helper functions, so you might want to look those up.

Also, don't use the standard RGB() function - it generates Win32/GDI compatible 24bit BGR codes iirc. Be warned about matching your colour with the pixel format - I've seen more than enough people get tripped up by setting a 32bit pixel colour for a 16bit texture (or similar) and wondering why it doesn't look right [smile]

hth
Jack

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!