Язык:
Русский
English
TColorRef (type) (WinTypes unit)
Declaration
TColorRef = Longint;
Remarks
TColorRef is a 32-bit value corresponding to a color, used by numerous GDI functions. It can be interpreted in three different ways, depending on the value of the high-order byte of the high-order word in the long integer.
- If that highest-order byte is zero, the next three bytes represent RGB
color intensities for blue, green, and red, respectively, so the value
$00FF0000 represents full-intensity, pure blue, $0000FF00 is pure green,
and $000000FF is pure red.
$00000000 is black, and $00FFFFFF is white.
RGB values can most easily be converted into TColorRef values using the
RGB function.
- If the highest-order byte is one, the next byte must be zero. The
low-order word (the next two bytes) form an index into a logical
palette. Thus, $01000000 is index zero (the first entry) of a palette.
Integer-type palette indexes can be converted into TColorRef values
using the GetNearestPaletteIndex function.
- If the highest-order byte is two, the next three bytes represent RGB
color intensities (as with RGB values described for a zero-highest
byte), but the value will be matched to the nearest color in the logical
palette in the current device context. Palette-relative RGB TColorRef
values can be produced from RGB values with the PaletteRGB function.
In order for palette index or palette-relative TColorRef values to work with a device context, an application with its own palette must select its palette into the device context being written to (using SelectPalette) and realize it (using RealizePalette) in order to have drawing functions use the correct colors from the palette. Similarly, before creating a logical drawing tool, the palette must be selected and realized if the colors are to take effect.