Convert Inno Setup Pascal Script TColor to HTML hex colour

寵の児 提交于 2019-12-13 12:51:00

问题


Inno Setup Pascal Script has colour variables like clBtnFace, clYellow in Delphi.

I like to know how can I convert any of those TColor to HTML hex colour.

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.

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....

Thanks in advance.


回答1:


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;

For the ColorToRGB, see Converting Inno Setup WizardForm.Color to RGB.



来源:https://stackoverflow.com/questions/39009484/convert-inno-setup-pascal-script-tcolor-to-html-hex-colour

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!