![]() |
|
|||||
|
Colors under .NET | |||||
ImageGlue uses a dedicated class for colors: XColor. XColor allows you to specify RGB colors as well as to use the System.Drawing.Color names for creating colors. You can create and XColor from a System.Drawing.Color or viceversa at any time. |
||||||
|
RGB Colors | |||||
An RGB color specifies the intensity of the Red, Green and Blue components of a color. Imagine it as a set of three overlapping colored lights. Any color can be created using a combination of these lights. We specify the intensity as a number from 0 to 255. 0 indicates that the light is off, 255 that it is fully on. So:
Some graphics packages specify color intensities as decimal numbers between 0 and 255 or as hexadecimal numbers between 00 and FF. You can use both these methods. For decimal numbers you must precede the number by 0d and for hexadecimal by 0x. So:
When working with HTML you may want to specify a color using an RGB Hex Code as used in HTML. So:
|
||||||
|
RGBA Color Strings | |||||
An RGBA color is exactly the same as an RGB color but includes a fourth component Alpha, which is a measure of transparency. The alpha value is optional and defaults to 255 opaque (i.e. not transparent). You cannot generally draw with an RGBA Color but you may wish to determine the color and opacity of a point on a canvas. Alpha is described more fully in the channels section. |
||||||
|
Relationships between Color Names and RGB Colors | |||||
Each of the System.Drawing.Color names corresponds to an RGB color. The particular RGB color is chosen to look correct rather than to fit in with the definitions of RGB color space. What this means is that if you want precise control over the color components of your colors you must explicitly use RGB colors. |