Registriert seit: 18. Jan 2003
110 Beiträge
Delphi 7 Professional
|
13. Feb 2003, 16:03
danke. hab scho was gefunden
Code:
procedure tform1.RGBtoHSV(Red, Green, Blue: Byte; var Hue: THue; var Saturation, Value: Byte);
var
Maximum, Minimum: Byte;
Rc, Gc, Bc: Single;
H: Single;
begin
Maximum := Max(Red, Max(Green, Blue));
Minimum := Min(Red, Min(Green, Blue));
Value := Maximum;
if Maximum <> 0 then
Saturation := MulDiv(Maximum - Minimum, 255, Maximum)
else
Saturation := 0;
if Saturation = 0 then
Hue := 0 // arbitrary value
else
begin
Assert(Maximum <> Minimum);
Rc := (Maximum - Red) / (Maximum - Minimum);
Gc := (Maximum - Green) / (Maximum - Minimum);
Bc := (Maximum - Blue) / (Maximum - Minimum);
if Red = Maximum then
H := Bc - Gc
else if Green = Maximum then
H := 2 + Rc - Bc
else
begin
Assert(Blue = Maximum);
H := 4 + Gc - Rc;
end;
H := H * 60;
if H < 0 then
H := H + 360;
Hue := Round(H);
end;
end;
|
|
Zitat
|