Hi.
I use Lazarus 1.6.2 with FPC 3.0.0 on Windows 10. I use htmlreport to create webpages.
My problem is the use of colorcodes. I want to use the color #D8FFF4. But the function Color2HTML translate that code to $00D8FFF4# and that gives a totally different color.
I've searched the internet for a converter but found nothing. Therefor I have 2 questions:
1. What does the colorcode $00000000# mean? It's not ?RGB.
2. What code should I use to get the colorresult I want?
Mailing lists / lazarus / 2017-03
Colorconversion in htmlreport
2 messages · 2 people ·
- BBart 1
- Ffrans 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
mvg
Frans van Leeuwen
M 06-51695390
frans wroteI want to use the color #D8FFF4. But the function Color2HTML translate that code to $00D8FFF4#
That makes no sense to me.
#D8FFF4 looks like HTML color coding, so calling ColorToHTML on that makes no sense (or the name of that makes no sense).
Here's a ColorToHtml function from the SynExportHtml unit that works correctly (at least in my limited tests):
function ColorToHTML(AColor: TColor): string;
var
RGBColor: TColorRef;
RGBValue: byte;
const
Digits: array[0..15] of char = '0123456789ABCDEF';
begin
Result := '';
case AColor of
clRed: Result := 'red';
clGreen: Result := 'green';
clBlue: Result := 'blue';
clPurple: Result := 'purple';
clYellow: Result := 'yellow';
clBlack: Result := 'black';
clWhite: Result := 'white';
clGray: Result := 'gray';
clMaroon: Result := 'maroon';
clFuchsia: Result := 'fuchsia';
clLime: Result := 'lime';
clNavy: Result := 'navy';
clAqua: Result := 'aqua';
clTeal: Result := 'teal';
clSilver: Result := 'silver';
end;
if (Result '') then
Exit;
RGBColor := ColorToRGB(AColor);
Result := '#000000';
{****************}
RGBValue := GetRValue(RGBColor);
if RGBValue > 0 then begin
Result[2] := Digits[RGBValue shr 4];
Result[3] := Digits[RGBValue and 15];
end;
{****************}
RGBValue := GetGValue(RGBColor);
if RGBValue > 0 then begin
Result[4] := Digits[RGBValue shr 4];
Result[5] := Digits[RGBValue and 15];
end;
{****************}
RGBValue := GetBValue(RGBColor);
if RGBValue > 0 then begin
Result[6] := Digits[RGBValue shr 4];
Result[7] := Digits[RGBValue and 15];
end;
end;Note that the represetation of TColor and HTML color (if you both write them out as hex) is not in the same order.
Bart
