本文整理自网络,侵删。
颜色转换函数: 从 Delphi 到 Html
{由 Delphi 的颜色常数转换到 Html 颜色}
function HexColorToHtmlColor(c: Integer): string;
var
R,G,B: Byte;
begin
R := c and $FF;
G := (c shr 8) and $FF;
B := (c shr 16) and $FF;
Result := #35 + Format('%.2x%.2x%.2x',[R,G,B]);
end;
--------------------------------------------------------------------------------
{从十六进制字符串转换到 Html 颜色}
function HexColorToHtmlColor(s: string): string;
var
i: Integer;
R,G,B: Byte;
begin
i := StrToInt(s);
R := i and $FF;
G := (i shr 8) and $FF;
B := (i shr 16) and $FF;
Result := #35 + Format('%.2x%.2x%.2x',[R,G,B]);
end;
相关阅读 >>
Delphi winapi: getforegroundwindow - 获取前台窗口的句柄
Delphi 10.3.x 截取字符串函数substring 和copy()常用字串符处理函数用法
更多相关阅读请进入《Delphi》频道 >>