我是德尔福学习者。我正在寻找一些代码来转换色调、饱和度和值的基本颜色。我在这个论坛上得到了它,我已经实现了它:
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Math;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure HSVToRGB(Const H, S, V: Real; Out R, G, B: Real);
const
SectionSize = 60/360;
var
F: real;
P, Q, T: real;
Section: real;
SectionIndex: integer;
begin
if H < 0 then
begin
R:= V;
G:= R;
B:= R;
end
else
begin
Section:= H/SectionSize;
SectionIndex:= Floor(Section);
F:= Section - SectionIndex;
P:= V * ( 1 - S );
Q:= V * ( 1 - S * F );
T:= V * ( 1 - S * ( 1 - F ) );
case SectionIndex of
0:
begin
R:= V;
G:= T;
B:= P;
end;
1:
begin
R:= Q;
G:= V;
B:= P;
end;
2:
begin
R:= P;
G:= V;
B:= T;
end;
3:
begin
R:= P;
G:= Q;
B:= V;
end;
4:
begin
R:= T;
G:= P;
B:= V;
end;
else
begin
R:= V;
G:= P;
B:= Q;
end;
end;
end;
end;
procedure RGBToHSV(Const R, G, B: Real; Out H, S, V: Real);
var
Range: real;
RGB: array[0..2] of real;
MinIndex, MaxIndex: integer;
begin
RGB[0]:= R;
RGB[1]:= G;
RGB[2]:= B;
MinIndex:= 0;
if G < R then MinIndex:= 1;
if B < RGB[MinIndex] then MinIndex:= 2;
MaxIndex:= 0;
if G > R then MaxIndex:= 1;
if B > RGB[MaxIndex] then MaxIndex:= 2;
Range:= RGB[MaxIndex] - RGB[MinIndex];
if Range = 0 then
begin
H:= -1;
S:= 0;
V:= R;
end
else
begin
case MaxIndex of
0:
begin
H:= (G-B)/Range;
end;
1:
begin
H:= 2 + (B-R)/Range;
end;
2:
begin
H:= 4 + (R-G)/Range;
end;
end;
S:= Range/RGB[MaxIndex];
V:= RGB[MaxIndex];
H:= H * (1/6);
if H < 0 then H:= 1 + H;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Hue, Saturation, Value: real;
Red, Green, Blue: integer;
begin
Red := GetRValue(Label1.Font.Color);
Green := GetGValue(Label1.Font.Color);
Blue := GetBValue(Label1.Font.Color);
Hue := RGBToHSV(GetRValue(Label1.Font.Color), GetGValue(Label1.Font.Color), GetBValue(Label1.Font.Color));
Saturation := RGBToHSV(GetRValue(Label1.Font.Color), GetGValue(Label1.Font.Color), GetBValue(Label1.Font.Color));
Value := RGBToHSV(GetRValue(Label1.Font.Color), GetGValue(Label1.Font.Color), GetBValue(Label1.Font.Color));
ShowMessage (FloatToStr(Hue) +','+ FloatToStr(Saturation)+',' + FloatToStr(Value));
end;
end.
在编译时 Delphi 抛出 3 Error as
[DCC Error] Unit1.pas(150): E2035 Not enough actual parameters。
在以下几行:
Hue := RGBToHSV(GetRValue(Label1.Font.Color), GetGValue(Label1.Font.Color), GetBValue(Label1.Font.Color));
Saturation := RGBToHSV(GetRValue(Label1.Font.Color), GetGValue(Label1.Font.Color), GetBValue(Label1.Font.Color));
Value := RGBToHSV(GetRValue(Label1.Font.Color), GetGValue(Label1.Font.Color), GetBValue(Label1.Font.Color));
如何删除错误?