# And, what is the origin of GetRValue series?

This topic is 2993 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I just used GetRValue to a D3DCOLOR, and I got the B value.
Is the data format of D3DCOLOR different from that of COLORREF?
And is there any macros used to get the R value of the D3DCOLOR?
((BYTE)((rgb)>>16) works, but it's not so beautiful. Must I create my own macro in every program?)

##### Share on other sites
Quote:
 Is the data format of D3DCOLOR different from that of COLORREF?

Yep. D3DCOLOR components are in byte order left-to-right: alpha, red, green, blue. COLORREF: alpha, blue, green, red.

So GetRValue for a D3DCOLOR does, indeed, return the blue vs red value.

I don't think there are built-in macros for accessing individual D3DCOLOR components. You could add yours to your d3d9types.h file if you're adventuresome.

Quote:
 ((BYTE)((rgb)>>16) works, but it's not so beautiful.

Actually, that's pretty close to (the opposite of) what's done to construct COLORREFs and D3DCOLORs. Take a look at d3d9types.h for the various D3DCOLOR "constructor" macros.

E.g.,
#define D3DCOLOR_ARGB(a,r,g,b)     ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))

EDIT: COLORREF is actually part of GDI and doesn't address the alpha value (which is rarely if ever used in GDI). So you're mixing GDI and DX. That's okay if you're careful, but using your own macros for DX is probably better as it's safer against revisions of GDI vs DX, etc.

[Edited by - Buckeye on July 12, 2010 9:11:42 AM]

1. 1
2. 2
Rutin
19
3. 3
4. 4
frob
14
5. 5

• 12
• 9
• 16
• 10
• 9
• ### Forum Statistics

• Total Topics
632594
• Total Posts
3007308

×