mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 14:36:09 +02:00
LazReport: TfrHTMExportFilter.ColorToHex can be optimized, from Alexey Torgashin, issue #40966
This commit is contained in:
parent
bae7ac120d
commit
e9e8f61f5a
@ -384,14 +384,25 @@ end;
|
||||
|
||||
|
||||
function TfrHTMExportFilter.ColorToHex(c: TColor): AnsiString;
|
||||
const
|
||||
SHexDigits: PChar = '0123456789ABCDEF';
|
||||
var
|
||||
s: AnsiString;
|
||||
r, g, b: byte;
|
||||
begin
|
||||
s:= IntToHex(ColorToRGB(c), 8);
|
||||
Result:= '#' + Copy(s, 7, 2) + Copy(s, 5, 2) + Copy(s, 3, 2);
|
||||
C:= ColorToRGB(C);
|
||||
r:= Red(C);
|
||||
g:= Green(C);
|
||||
b:= Blue(C);
|
||||
SetLength(Result{%H-}, 7); // #rrggbb
|
||||
Result[1]:= '#';
|
||||
Result[2]:= SHexDigits[Hi(r)];
|
||||
Result[3]:= SHexDigits[Lo(r)];
|
||||
Result[4]:= SHexDigits[Hi(g)];
|
||||
Result[5]:= SHexDigits[Lo(g)];
|
||||
Result[6]:= SHexDigits[Hi(b)];
|
||||
Result[7]:= SHexDigits[Lo(b)];
|
||||
end;
|
||||
|
||||
|
||||
procedure TfrHTMExportFilter.AppendLine(const s: AnsiString);
|
||||
begin
|
||||
outputLines.Add(s);
|
||||
|
Loading…
Reference in New Issue
Block a user