I'm trying to understand if I'm doing it right, because sometimes it gets a little bit fuzzy when I convert the colors back and forward.
The way I convert D3DCOLORVALUE
to D3DCOLOR
:
D3DCOLORVALUE D3DCOLOR_ConvertTo_D3DCOLORVALUE(D3DCOLOR color)
{
D3DCOLORVALUE color2;
color2.a = ((color & 0xff000000) >> 24) / 255.0f;
color2.r = ((color & 0x00ff0000) >> 16) / 255.0f;
color2.g = ((color & 0x0000ff00) >> 8) / 255.0f;
color2.b = ( color & 0x000000ff) / 255.0f;
return color2;
};
Now to convert from D3DCOLOR
to D3DCOLORVALUE
:
D3DCOLOR D3DCOLORVALUE_ConvertTo_D3DCOLOR(const D3DCOLORVALUE& color)
{
COLORREF color2 = (((DWORD)(color.a * 255.0f)) << 24) |
(((DWORD)(color.r * 255.0f)) << 16) |
(((DWORD)(color.g * 255.0f)) << 8) |
(((DWORD)(color.b * 255.0f)));
return color2;
};
It works ok for some part, but when I set the B(Blue) channel to 0, the R(Red) and G(Green) channels changing directly to 0, which brings the color red. What could possibly go wrong here with the color conversion I'm doing?
TIA!
User contributions licensed under CC BY-SA 3.0