![]() |
Home | Articles | Links | Contact | ![]() |
Title | Convert Delphi TColor into HTML colors |
---|---|
Description | A function for transforming Delphi colors into HTML colors |
Date | 10/03/2000 |
Last revision |
The following function
transform a Delphi TColor into a string containing the HTML index for the same
color:
function ColorToHTML( Color: TColor): string; begin result := Format( '#%.2x%.2x%.2x', [ GetRValue( Color), GetGValue( Color), GetBValue( Color)]); end; |
This function uses the "Get?Value" functions to get the red, green and blue components of the TColor, and then the Format function to put then together again in the form of hexadecimal numbers with a precision of two for each of the components. We add a # at the beginning of the format string as the final touch and that's it.
|