views:

129

answers:

7

The VS debugger gives me:

_Color = "{Name=ff000040, ARGB=(255, 0, 0, 64)}"

how can I "see" what color is?

I tried a html page:

<html>
<div style="background: rgba(255, 0, 0, 64);">________<div>
<h1 style="background-color: ff000040">hello</h1>
</html>

doesn't work.

+3  A: 

You probably need to strip the alpha values off when using it in HTML, since the color tags don't support it. You also may or may not need the pound sign before using hex values for color. So you want #000040 instead of #FF000040.

Andrew Koester
Alpha values should supported when used with rgba, no? The second part of your answer is correct. Alpha channels are ( as far as I know ) not supported when colors are specified with hexadecimal values.
Atømix
it depends of CSS, but al least in FF this does not displayed when using `rgba(0, 0, 64, 255)`
serhio
After looking at http://www.domedia.org/oveklykken/css-transparency.php it appears the problem with it's actually RGBA, and alpha is a float, so it'd really be rgba(0,0,64,1), where 1 is 100% opaque, or 255.
Andrew Koester
@Andrew: `<div style="background-color: rgba(0,0,64,1);">________<div>` works in FF, but not in IE.
serhio
@serhio Internet Explorer 8 does not support transparency in CSS3 as noted in https://connect.microsoft.com/IE/feedback/details/331735/no-css-opacity-available-in-ie8-standards-mode
Andrew Koester
@Andrew: Argh! I forgot about that! Opacity is ( logically ) a percentage... not a 0-255 index. @Sergio: Don't test in IE. You'll hurt yourself.
Atømix
+4  A: 

You can use this website.

You can also use Visual Color Picker, an excellent program.

SLaks
yes, so i should ignore alpha?...
serhio
Yes, you should. (Unless it isn't 255) Alpha means opacity; 255 means fully opaque.
SLaks
apparently for browsers opacity 1(Firefox) = 255(Visual Studio)
serhio
+2  A: 

Ignore the first 2 letters (ff) of the color: ff000040. This is the alpha value and ff means it's opaque. So the real color is #000040. You can see it like this:

<div style='width:100px;height:100px;background-color:#000040'></div>
Keltex
A: 

The A in ARGB stands for alpha (the opaqueness/transparency of the image) - CSS styles use RGB by default. You can programmatically generate the colour with the alpha or use CSS/HTML to generate the colour after dropping the alpha (#000040).

amelvin
A: 

You can use the System.Drawing.ColorTranslator to convert your colour to HTML. It has a .ToHtml() method that is what you need in your original example.

For example, to see a named color, you could do:

ColorTranslator.ToHtml(Color.SaddleBrown)

and put it into your web page as you have shown.

SLC
thanks. I just need to see it in debug, not show or something else
serhio
+1  A: 

The VS debugger is in ARGB order.

CSS is in RGBA order: (A stands for Alpha, which is from 0 ( invisible ) to 255 ( opaque )

Try this:

<html>
 <div style="background: rgba(0, 0, 64, 1.0);">________<div>
 <h1 style="background-color: #000040">hello</h1>
</html>

As far as I know, you can't specify opacity with hexcode color ( the second example ). At least, it doesn't work in FF.

Atømix
apparently need alpha 255=>1
serhio
A: 

A Debugger Visualizer for the System.Drawing.Color type can be obtained here: http://code.google.com/p/colorvisualizer/ or even here: http://www.codeproject.com/KB/macros/ZetaColorVisualizer.aspx

JJS