Delphi-Quellcode:
function HTMLColorToTColor(AHTMLColor:
String): TColor;
begin
if pos('
#', AHTMLColor) <> 1
then
AHtmlColor := '
#' + AHTMLColor;
AHTMLColor := StringReplace(AHTMLColor, '
#', '
$', [rfReplaceAll]);
if length(AHTMLColor) = 7
then
begin
try
result :=
RGB(strtoint(copy(AHTMLColor, 1, 3)),
strtoint('
$' + copy(AHTMLColor, 4, 2)),
strtoint('
$' + copy(AHTMLColor, 6, 2)));
except
result := clBlack;
end;
end else result := clBlack;
end;
Eine andere Variante wäre einfach die ersten beiden HexZeischen mit den letzten beiden Hex-Zeischen zu tauschen und dann einfach mit
StrToInt(StringReplace(AHTMLColor, '#', '$', [rfReplaceAll]));
die farbe nehmen. Wenn dabei ein Fehler auftritt stimmt das format auch nicht