procedure TForm1.RGB(Sender: TObject; ScrollCode: TScrollCode;
var ScrollPos: Integer);
var RGB_R, RGB_G, RGB_B : Real;
HLS_H, HLS_L, HLS_S : Real;
HSV_H, HSV_S, HSV_V : Real;
max_Farbwert : real;
min_Farbwert : real;
Differenz : real;
Summe : real;
RGB_R_temp, RGB_G_temp, RGB_B_temp : Real;
HLS_H_temp, HLS_L_temp, HLS_S_temp : Real;
HSV_H_temp, HSV_S_temp, HSV_V_temp : Real;
begin
RGB_R := Scrollbar1.Position;
RGB_G := Scrollbar2.Position;
RGB_B := Scrollbar3.Position;
max_Farbwert := max(RGB_R, max(RGB_G,RGB_B));
min_Farbwert := min(RGB_R, min(RGB_G,RGB_B));
Differenz := max_Farbwert - min_Farbwert;
Summe := max_Farbwert + min_Farbwert;
//Berechnung RGB-->HLS
RGB_R_temp:=RGB_R/255;
RGB_G_temp:=RGB_G/255;
RGB_B_temp:=RGB_B/255;
HLS_L:=(max_Farbwert+min_Farbwert)/2;
if min_Farbwert=max_Farbwert
then
begin
HLS_H:=0;
HLS_S:=0;
end;
if (min_Farbwert <> max_Farbwert)
then
begin
if (HLS_L < 0.50)
then HLS_S:=Differenz/Summe;
if (HLS_L >= 0.50)
then HLS_S:=Differenz/(2-Differenz);
if RGB_R_temp = max_Farbwert
then HLS_H := (RGB_G - RGB_B) / Differenz;
if RGB_G_temp = max_Farbwert
then HLS_H := 2 + (RGB_B - RGB_R) / Differenz;
if RGB_B_temp = max_Farbwert
then HLS_H := 4 + (RGB_R - RGB_G) / Differenz;
HLS_H:=HLS_H/6;
if (HLS_H<0)
then HLS_H:=HLS_H+1;
end;
scrollbar4.Position := round(HLS_H*360);
scrollbar5.Position := round(HLS_L*100);
scrollbar6.Position := round(HLS_S*100);
end;