Colors/es

From Lazarus wiki
Revision as of 14:59, 17 September 2015 by Jma sp (talk | contribs) (→‎Editando colores)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Overview

In the LCL TColor is the standard color type. It is compatible with Delphi's TColor. TColor can represent either an RGB (3x8bit) value, or a system color like clDefault. The LCL can also work with the fpImage system which uses the TFPColor type (which is RGBA (4x16bit), not RGB (3x8bit) like TColor).

Conversions between TColor and RGB values

The Graphics unit provides the following functions:

function Blue(rgb: TColor): BYTE; // does not work on system color
function Green(rgb: TColor): BYTE; // does not work on system color
function Red(rgb: TColor): BYTE; // does not work on system color
function RGBToColor(R, G, B: Byte): TColor;
procedure RedGreenBlue(rgb: TColor; out Red, Green, Blue: Byte); // does not work on system color
function FPColorToTColor(const FPColor: TFPColor): TColor;
function TColorToFPColor(const c: TColor): TFPColor; // does not work on system color
function IsSysColor(AColor: TColorRef): Boolean;

Convert TColor to/from string

Functions to convert strings like "25500" or "$AA0088" or "clNavy" to TColor:

  • StringToColor
  • StringToColorDef

To convert TColor to a nice string:

  • ColorToString