type TColor32 = type Longword;
type PColor32 = ^TColor32;
A simple ARGB color quad, compatible with 32-bit DIBs.
TColor32 holds color information in ARGB format:
Bits 32...24 | Bits 23...16 | Bits 15...8 | Bits 7...0 |
---|---|---|---|
Alpha
|
Red
|
Green
|
Blue
|
This order is different from ABGR pixel format used by most Windows API functions and implemented in Delphi as TColor type. A couple of functions are provided to convert colors between different standards: Color32, WinColor.
The alpha component is responsible for pixel’s opacity: zero value corresponds to complete transparency, and the value of 255 corresponds to completely opaque pixels.
Graphics32 specifies several pre-defined Color Constants, which are similar to standard ones except that they have properly filled alpha value and swapped red and blue components.
TColor32Entry = packed record
case Integer of
0: (A: Byte;
B: Byte;
G: Byte;
R: Byte);
1: (ARGB: TColor32;);
2: (Planes: array [0..3] of Byte);
3: (Components: array [TColor32Component] of Byte);
end;
type PColor32Entry = ^TColor32Entry;
A useful type for gaining fast direct read/write access to the components of TColor32 by typecasting. The following code segment shows how this typecasting can be used in different manners - we recommend using these approaches instead of auxiliary functions like RedComponent etc.:
var
AColor32: TColor32;
I: Integer;
begin
// Sets values to individual components
TColor32Entry(AColor32).A := 255;
TColor32Entry(AColor32).R := 127;
TColor32Entry(AColor32).G := 63;
TColor32Entry(AColor32).B := 31;
//Sets all planes or components ("channels") to a different random value
with TColor32Entry(AColor32) do
for I := Low(Planes) to High(Planes) do
Planes[I] := Random(255);
//Write value of Alpha component to Red, Green and Blue components
with TColor32Entry(AColor32) do
begin
Components[ccRed] := Components[ccAlpha];
Components[ccGreen] := Components[ccAlpha];
Components[ccBlue] := Components[ccAlpha];
end;
end;
type TColor32Component = (ccBlue, ccGreen, ccRed, ccAlpha);
An enumerated type that specifies a given TColor32 component or plane.
type TColor32Components = set of TColor32Component;
A set of TColor32Component which can be used to specify zero or more components. The order of defined components has no importance. To construct a set of components from booleans indicating component presence, use function Color32Components. If an empty set is passed to a routine that uses this type, this will (and should) in most cases lead to no processing.
type TColor32Array = array [0..0] of TColor32;
type PColor32Array = ^TColor32Array;
A reference to array of TColor32-typed values.
Most likely you will never use the TColor32Array type itself, however PColor32Array is the one of some importance. It provides indexed access to color values stored in memory. For example, in TBitmap32, it is used to access pixel data.
type TArrayOfColor32 = array of TColor32;
A dynamic array of TColor32-typed values.
You may use the standard SetLength function for array allocation and dynamic size changes.
Do not confuse PColor32Array and TArrayOfColor32 types. While the first one holds the pointer to a memory location, the second one is a fully functional dynamic array.
type TPalette32 = array [Byte] of TColor32;
type PPalette32 = ^TPalette32;
A fixed-size array of 256 TColor32-typed values.
TPalette32 type is mostly used to simulate palette-based operations.
TBitmap32, Color Constants, Color32, Color32Components, RedComponent, WinColor
Copyright ©2000-2024 Alex Denisov and the Graphics32 Team - Graphics32 2.0 - Help file built on 18 Feb 2024