将Inno Setup Pascal脚本TColor转换为HTML十六进制颜色 [英] Convert Inno Setup Pascal Script TColor to HTML hex colour
问题描述
Inno Setup Pascal脚本在Delphi中具有颜色变量,如 clBtnFace
, clYellow
。
Inno Setup Pascal Script has colour variables like clBtnFace
, clYellow
in Delphi.
我想知道如何将这些 TColor
中的任何一个转换为HTML十六进制颜色。
I like to know how can I convert any of those TColor
to HTML hex colour.
例如,如果我将 clBtnFace
转换为HTML十六进制颜色,结果应该是#497AC2
。如果我将 clYellow
转换为HTML十六进制颜色,结果应该是#FFFF00
。
For example, if I convert clBtnFace
to a HTML hex colour, the result should be #497AC2
. And if I convert clYellow
to a HTML hex colour, the result should be #FFFF00
.
我发现上面有很多例子,但它们是RGB颜色的。我希望将 TColor
转换为 HTML十六进制颜色,以在我的Pascal Script中的ImageMagick的命令行参数中用作十六进制颜色,例如 ... xc:#497AC2 ...
。
I found many examples for above, but they're for RGB colours. I want to convert TColor
to HTML hex colour to use as hex colour in the command line parameters for ImageMagick in my Pascal Script like ...xc:#497AC2...
.
预先感谢。
推荐答案
function ColorToWebColorStr(Color: TColor): string;
var
RGB: Integer;
begin
RGB := ColorToRGB(Color);
Result :=
UpperCase(Format('#%.2x%.2x%.2x', [Byte(RGB), Byte(RGB shr 8), Byte(RGB shr 16)]));
end;
对于 ColorToRGB
,请参阅将Inno Setup WizardForm.Color转换为RGB 。
这篇关于将Inno Setup Pascal脚本TColor转换为HTML十六进制颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!