Delphi里面的颜色和HTML的颜色互转
function HtmlToColor(HColor: Integer): Integer;
var
sColorMsg: string;
srValue, sgValue, sbValue: string;
irValue, igValue, ibValue: Integer;
begin
sColorMsg := IntToHex(HColor, 6);
srValue := '$' + Copy(sColorMsg, 1, 2);
sgValue := '$' + Copy(sColorMsg, 3, 2);
sbValue := '$' + Copy(sColorMsg, 5, 2);
irValue := StrToInt(srValue);
igValue := (StrToInt(sgValue) shl 8);
ibValue := (StrToInt(sbValue) shl 16);
Result := irValue + igValue + ibValue;
end;
function ColorToHtml(DColor:TColor):string;
var
tmpRGB : TColorRef;
begin
tmpRGB := ColorToRGB(DColor) ;
Result:=Format('#%.2x%.2x%.2x',
[GetRValue(tmpRGB),
GetGValue(tmpRGB),
GetBValue(tmpRGB)]) ;
end; {function ColorToHtml}