Click here to Skip to main content

Get Known Color from int value

if you think Color myColor = Color.FromArgb(0); will give you the known color black, then you are wrong. you need to get it from the colortranlator class. like this:Color c = ColorTranslator.FromWin32(0);So what am i saying ?, is Color.FromArgb(0) not the same as ColorTranslator.FromWin32(
Sign Up to vote bad good
Add a reason or comment to your vote: x
Votes of 3 or less require a comment
See more: C#

if you think Color myColor = Color.FromArgb(0); will give you the known color black, then you are wrong. you need to get it from the colortranlator class. like this:

Color c = ColorTranslator.FromWin32(0);

So what am i saying ?, is Color.FromArgb(0) not the same as ColorTranslator.FromWin32(0), well it is and it is'nt, its the same color (black), but the color struct is not the same. try it.

Posted 17 Nov '09


Sign Up to vote bad good
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Alternative 1

I think you are confusing how the FromArgb method works. It takes a 32 bit number in the format AARRGGBB, where each element of the color is an 8 bit number of the value 0 to 255. Setting the color to zero creates a black color, but it is transparent (the alpha channel is zero). To set black with an opaque color, you need to add 4278190080 to the value (0xFF000000), which is basically ORing 0xFF000000 with the desired color. You can either do that, or remember to set the Color.A channel to 255 after you call FromArgb() in your code.

  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Your Filters
Interested
Ignored
     
  1. Wonde Tadesse (1,210)
  2. SAKryukov (398)
  1. SAKryukov (9,712)
  2. Christian Graus (6,009)
  3. OriginalGriff (4,736)
  4. thatraja (4,349)
  5. Abhinav S (4,335)

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
-- There are no messages in this forum --

Advertise | Privacy | Mobile
Web01 | 2.5.120210.1 | Last Updated 21 Nov 2009
Copyright © CodeProject, 1999-2012
All Rights Reserved. Terms of Use
Layout: fixed | fluid