Pipette

TColor

The format TColor, used in the Delphi programming, is also based on the RGB color model. It translates the three RGB values into a single value, which accepts the range from 0 to 16777215.

The RGB values are in the following relation to the TColor value:

TColor = R or (G shl 8) or (B shl 16)

The following relationship applies when converting the TColor value in the components R, G and B:

R = TColor and $FF
G = (TColor shr 8) and $FF
B = (TColor shr 16) and $FF

The operators "shl" (shift left), "shr" (right shift), "and" and "or" are bitwise operators. This means that they work at the binary level (for example, 1101010 or 1001) rather than the numerical level (for example 2, 17 or 345). A left-shift (SHL) implies a shift of the ones and the zeros to the left by the value behind, a right-shift (shr) a shift of the ones and the zeros to the right by the value behind.

The bitwise "or" is used for two sequences of the same lenght and links couples of the same position with a logical "or" (for example: 1010 or 1100 = 1110). The bitwise "and" is used for two sequences of the same lenght and links couples of the same position with a logical "and". Here the result is 1 if both bits are 1, otherwise 0 (for example: 1010 and 1100 = 1000).

In the program pipette, the TColor value is displayed in the line "TColor".

Related Topics