(CodeLib-Manager)
Registriert seit: 9. Jul 2003
Ort: Ensdorf
6.723 Beiträge
Delphi XE Professional
|
Re: Farbwert umwandeln
22. Jul 2004, 10:52
Hi!
Hab das mal schnell zusammengezimmert:
Delphi-Quellcode:
function ColorToHTML(aColor: TColor): string;
var
r, g, b: Byte;
procedure TColor2RGB( const Color: TColor; var R, G, B: Byte);
begin
// convert hexa-decimal values to RGB
R := Color and $FF;
G := (Color shr 8) and $FF;
B := (Color shr 16) and $FF;
end;
begin
TColor2RGB(aColor, r, g, b);
result := IntToHex(r, 2)+IntToHex(g, 2)+IntToHex(b, 2);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
Var Pt:TPoint; DC:HDC;
begin
GetCursorPos(Pt);
DC:=CreateDC(' DISPLAY', NIL, NIL, NIL);
label1.Caption := inttostr(GetPixel( DC,Pt.x,Pt.y));
label2.Caption:=' #'+(ColortoHTML(strtoint(Label1.Caption)));
end;
Ciao fkerber
Frederic Kerber
|
|
Zitat
|