I often have convert Web colour to Delphi (on Windows), It is simple, here is how.
Here are the color codes for Navy:
Web colour (CSS/HTML): #000080The difference is because:
Web uses RGB format (Red-Green-Blue)So for Navy:
Web: RGB(0,0,128) = #000080You can convert between them by swapping the first and last byte pairs.
function ConvertWebColorToDelphi (const WebColor: string) : TColor;
var
R, G, B: Byte;
begin
// Remove # if present
if WebColor[1] = '#' then
WebColorHex := Copy(WebColor, 2)
else
WebColorHex := WebColor;
// Convert hex to RGB
R := StrToInt('$' + Copy(WebColorHex, 1, 2));
G := StrToInt('$' + Copy(WebColorHex, 3, 2));
B := StrToInt('$' + Copy(WebColorHex, 5, 2));
// Convert RGB to BGR
Result := RGB(B, G, R);
end;
// Usage
var
NavyColor : TColor;
begin
NavyColor := ConvertWebColorToDelphi ('#000080'); // Converts web navy to Delphi navy
end;