I've figured out how to translate a color to a win32 color, but I can't
figure out how to translate a win32 color back to a color.
Can anyone help me out with this one?
Thanks.
--Terry
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.512 / Virus Database: 309 - Release Date: 8/22/2003
"JustMe" <temi...@sasktel.net> wrote in message
news:vl4tr06...@corp.supernews.com...
Thanks for your reply. I'm still stumped though (must be the heat).
Anyway, let's say I start with color.yellow. The Win32 value for yellow is
65535.
Now that I have the win32 value of 65535, I need to translate that back
to -256 (which is the color.yellow.toargb value).
This is where I'm stumped. How can I translate the -256 value back to 65535
(or any other color values) in the CF?
Thanks,
Terry
"Alex Feinman [MVP]" <publi...@alexfeinman.com> wrote in message
news:eY0FPhBc...@TK2MSFTNGP12.phx.gbl...
I'm not sure why do you say the Win32 value for yellow is 65535 (0x00ffff).
This would be Cyan (G+B)
"JustMe" <temi...@sasktel.net> wrote in message
news:vl53ri...@corp.supernews.com...
When I do colortranslator.towin32(color.yellow) I get 65535.
Still puzzled.
Thanks again,
-Terry
"Alex Feinman [MVP]" <publi...@alexfeinman.com> wrote in message
news:u6ummFC...@tk2msftngp13.phx.gbl...
The ARGB value is AARRGGBB. ARGB for Blue is 0xff0000ff
Given this in order to convert Win32 color (COLORREF value) and back, you
need to use the following:
int winColor = -255;
Color clr = Color.FromArgb( winColor & 0xff, (winColor >> 8) & 0xff,
(winColor >> 16) & 0xff);
winColor = clr.R + clr.G << 8 + clr.B << 16;
"JustMe" <temi...@sasktel.net> wrote in message
news:vl56l33...@corp.supernews.com...
private uint RGB(Color color)
{
// Format the value of color - 0x00bbggrr
return ((uint) (((uint) (color.R) | ((uint) (color.G) << 8)) | (((uint)
(color.B)) << 16)));
}
private Color UnRGB(int color)
{
return Color.FromArgb(color & 0xFF, (color & 0xFF00) >> 8, (color &
0xFF0000) >> 16);
}
HTH
--
Tim Wilson
Windows Embedded MVP
"JustMe" <temi...@sasktel.net> wrote in message
news:vl56l33...@corp.supernews.com...
I don't suppose you'd be able to translate this into vb.net could you? It's
exactly what I'm looking for, but I'm a bit lost when it comes to
hexadecimal stuff.
Thanks
--Terry
"Tim Wilson [MVP]" <Tim_W...@Rogers.com> wrote in message
news:ekovMzIc...@TK2MSFTNGP10.phx.gbl...
Version: 6.0.512 / Virus Database: 309 - Release Date: 8/23/2003
Private Function RGB(ByVal color As Color) As Integer
' Format the value of color - 0x00bbggrr
Return Convert.ToInt32((Convert.ToInt32(color.R)) Or
(Convert.ToInt32(color.G) << 8) Or (Convert.ToInt32(color.B) << 16))
End Function
Private Function UnRGB(ByVal color As Integer) As Color
Return System.Drawing.Color.FromArgb((color And &HFF), ((color And &HFF00)
>> 8), ((color And &HFF0000) >> 16))
End Function
--
Tim Wilson
Windows Embedded MVP
"JustMe" <temi...@sasktel.net> wrote in message
news:vl6oqc6...@corp.supernews.com...
Some days I don't know what I'd do without all you MVP's!!!
Have a great day!
--Terry
"Tim Wilson [MVP]" <Tim_W...@Rogers.com> wrote in message
news:%23Q5GtGK...@TK2MSFTNGP10.phx.gbl...