Delphi的颜色数值的位排列顺序是BGR而HTML则是RGB。
所以你只要作一个操作将这几位调换一下并转换成为十六进制就可以了
function DELPHIColorToRGB(Color:TColor):integer;
var
i:integer;
myrgb:array[0..2] of BYTE;
begin
for i:=0 to 2 do
begin
myrgb[i]:=Color and $ff;
Color:=Color shr 8;
end;
Result:=RGB(myrgb[2],myrgb[1],myrgb[0]);
end;
Converts a TColor value into an RGB representation of the color.
Unit
Graphicsor QGraphics
Category
graphics utilities
Delphi syntax:
function ColorToRGB(Color: TColor): Longint;
C++ syntax:
extern PACKAGE int __fastcall ColorToRGB(TColor Color);
Description
Call ColorToRGB to obtain an RGB representation of a color for using with Windows API calls. ColorToRGB strips away the information that is stored in the highest order bits about which palette to use for colors that are not always available.