delphi颜色转换函数


function coloto111(color:TColor):String ;
var
r,g,b:Byte;
begin


r:=GetRValue(color);
g:=GetgValue(color);
b:=GetbValue(color);


//memo2.Lines.Add (inttostr(r)+' '+inttostr(g)+' '+inttostr(b));
//memo2.Lines.Add ('$' + IntToHex (TColor (RGB (r, g, b)), 8)) ;
Result:= '$' + IntToHex (TColor (RGB (r, g, b)), 8);
end;

function HexColorToHtmlColor(c: Integer): string;
var
R,G,B: Byte;
begin
R := c and $FF;
G := (c shr 8) and $FF;
B := (c shr 16) and $FF;
Result := #35 + Format('%.2x%.2x%.2x',[r,g,b]);
end;


function colortohexcolor(c:Integer):String ;
const
Digits : array[0..$F] of Char = '0123456789ABCDEF';
var
rr,gg,bb : byte;
begin
rr := getRvalue(c); {分解红色分量}
gg := getGvalue(c); {分解绿色分量}
bb := getBvalue(c); {分解蓝色分量}
Result:= '#' + Digits[rr shr 4] + Digits[rr and $F] +
Digits[gg shr 4] + Digits[gg and $F] + Digits[bb shr 4] +
Digits[bb and $F];{显示相应十六进制数值}


end;




procedure TForm1.Button1Click(Sender: TObject);
begin

memo1.Lines.Add(coloto111(clBlue)) ;
memo1.Lines.Add(colortohexcolor(clBlue ));
memo1.Lines.Add(ColorToString(clBlue ));
memo1.Lines.Add(HexColorToHtmlColor(clBlue ));
//www.delphitop.com
Label1.Color:=StrToInt(coloto111(clBlue))
end;

联系电话:
020-00000000
联系电话:
020-00000000
联系电话:
020-12345678