#208 – Color Values Are Stored as RGB Values
February 5, 2011 2 Comments
Although we can specify colors for brushes in WPF using predefined names, e.g. “DarkBlue”, each color is actually stored as an RGB (Red/Green/Blue) value.
For example, if we specify a color as “Lavender” and then look at the Color property of the SolidColorBrush at runtime, we see that the color is actually a structure containing a number of fields.
The main fields in this structure are the R, G, and B fields, which specify Red, Green and Blue values that make up the resulting color. Each value has a range from 0-255. So “Lavender” is: R=230, G=230, B=250.
The A field represents the alpha channel (also 0-255), which dictates that transparency of the object (0 = fully transparent, 255 = fully opaque).
The ScA, ScR, ScG, and ScB properties allowing reading or writing the color in the scRGB format.
Pingback: Tweets that mention #208 – Color Values Are Stored as RGB Values « 2,000 Things You Should Know About WPF -- Topsy.com
Pingback: #860 – Making a Tooltip Partially Transparent | 2,000 Things You Should Know About WPF