hallo,
ich hab da ein Paar Codezeilen aufgeschnappt die, glaube ich, dass erledigen, was du brauchst
Delphi-Quellcode:
uses SysUtils, Graphics;
// converts a color to an html color string
// clRed => #FF0000
function Sto_ColorToHtml(
const Color: TColor):
String;
var
iRgb: Longint;
iHtml: Longint;
begin
// convert system colors to rgb colors
iRgb := ColorToRGB(Color);
// change BBGGRR to RRGGBB
iHtml := ((iRgb
and $0000FF)
shl 16)
or // shift red to the left
( iRgb
and $00FF00)
or // green keeps the place
((iRgb
and $FF0000)
shr 16);
// shift blue to the right
// create the html string
Result := '
#' + IntToHex(iHtml, 6);
end;
// converts an html color string to a color,
// can raise an EConvertError exception
// #0000FF -> clBlue
function Sto_HtmlToColor(Color:
String): TColor;
var
iHtml: Longint;
begin
// remove the preceding '#'
if (Length(Color) > 0)
and (Color[1] = '
#')
then
Delete(Color, 1, 1);
// convert html string to integer
iHtml := StrToInt('
$' + Color);
// change RRGGBB to BBGGRR
Result := ((iHtml
and $FF0000)
shr 16)
or // shift red to the right
( iHtml
and $00FF00)
or // green keeps the place
((iHtml
and $0000FF)
shl 16);
// shift blue to the left
end;
grüße, daniel