IGxColorClass.FromValue

Syntax

FromValue(Value: Integer): IGxColor;

Parameters

Value. Color value.

Description

The FromValue method returns the object that contains the color, which value is passed by the Value parameter.

Comments

To get value of the required color, execute the following transformations:

  1. Knowing components of the required color (B, G, R), cast these values to hexadecimal view (the A component is not used).

  2. Get one hexadecimal 32-bit number by merging separate components in the following order: B, G, R.

  3. Cast the obtained hexadecimal number to decimal view. Substitute this value as a value of the Value parameter to get color.

To get the B, G, R components of standard colors, use values determined for constants of the GxKnownColor enumeration. Color components in the values of constants are specified in the following order: A, R, G, B.

For example: GxKnownColor.Red = 4294901760^10 = FFFF0000^16, where A = FF, R = FF, G = 00, B = 00. The required value of the FromValue method is: 0000FF^16 = 255^10.

Example

  1. If it is required to get shade of the blue color: the B, G, R components in the decimal view have values 204, 51 and 51 respectively. In the hexadecimal view - CC, 33 and 33. Merge these components and get the number CC3333^16 = 13382451^10. The obtained 13382451 value is substituted into the FromValue method to get shade of the blue color.

  2. If it is required to get red color: the B, G, R components in the decimal view have values 0, 0 and 255 respectively. In the hexadecimal view - 00, 00 and FF. Merge these components and get the number 0000FF^16 = 255^10. The obtained 255 value is substituted into the FromValue method to get red color.

Sub UserColor;
Var
    Color, RedColor: IGxColor;
Begin
    Color := GxColor.FromValue(13382451);
    RedColor := GxColor.FromValue(255);
End Sub UserColor;

See also:

IGxColorClass