-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathADCLRUN.PAS
145 lines (131 loc) · 3.71 KB
/
ADCLRUN.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
unit adclrun;
interface
uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
Buttons, ExtCtrls, ComCtrls,Registry;
type
TADCLRDLG = class(TForm)
OKBtn: TButton;
CancelBtn: TButton;
Bevel1: TBevel;
REDED: TEdit;
RedS: TUpDown;
REDCAP: TLabel;
GreenED: TEdit;
GreenS: TUpDown;
GreenCAP: TLabel;
BlueED: TEdit;
BlueS: TUpDown;
BlueCAP: TLabel;
PreviewBTN: TButton;
procedure PreviewBTNClick(Sender: TObject);
procedure CancelBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
public
{ Public declarations }
end;
var
ADCLRDLG: TADCLRDLG;
function ShowADCLRDLG(var r,g,b : integer; Mode : integer) : integer;
implementation
{$R *.DFM}
uses DPEMForm,Photo;
var tft : TFPhoto;
tmpbmp : TBitmap;
modi : boolean;
hpal : HPalette;
dmode : integer;
function ShowADCLRDLG(var r,g,b : integer; Mode : integer) : integer;
begin
dmode := mode;
with TADCLRDLG.Create(Application) do
try
result := ShowModal;
if Result = mrOK then
begin
case dmode of
0: // RGB adjust dialog
begin
r := Reds.Position;
g := GreenS.Position;
b := BlueS.Position;
RegIniFile := TRegIniFile.Create(DPEIniName);
RegIniFile.WriteInteger('RGBAdjust','R',RedS.Position);
RegIniFile.WriteInteger('RGBAdjust','B',BlueS.Position);
RegIniFile.WriteInteger('RGBAdjust','G',GreenS.Position);
RegIniFile.Free;
end;
1: // HSV adjust dialog
begin
r := RedS.Position;
g := GreenS.Position;
b := BlueS.Position;
RegIniFile := TRegIniFile.Create(DPEIniName);
RegIniFile.WriteInteger('HSVAdjust','H',RedS.Position);
RegIniFile.WriteInteger('HSVAdjust','S',GreenS.Position);
RegIniFile.WriteInteger('HSVAdjust','V',BlueS.Position);
RegIniFile.Free;
end;
end;
end;
finally
Free;
end;
end;
procedure TADCLRDLG.PreviewBTNClick(Sender: TObject);
begin
modi := True;
tmpbmp.Palette := hpal;
tft.Photo.Canvas.Draw(0,0,tmpbmp);
case dmode of
0: tft.RGBAdjustColor(Reds.Position,GreenS.Position, BlueS.Position,false);
1: tft.HSVAdjustColor(Reds.Position,GreenS.Position, BlueS.Position,false);
end;
end;
procedure TADCLRDLG.CancelBtnClick(Sender: TObject);
begin
if modi then tft.Photo.Picture.Bitmap.Assign(tmpbmp);
end;
procedure TADCLRDLG.FormCreate(Sender: TObject);
begin
RegIniFile := TRegIniFile.Create(DPEIniName);
case dmode of
0:
begin
RedS.Position := RegIniFile.ReadInteger('RGBAdjust','R',0);
BlueS.Position := RegIniFile.ReadInteger('RGBAdjust','B',0);
GreenS.Position := RegIniFile.ReadInteger('RGBAdjust','G',0);
end;
1:
begin
REDS.Max := 359;
REDS.Min := -359;
REDCap.Caption := '&H:';
GreenCap.Caption := '&S:';
BlueCap.Caption := '&V:';
RedED.Left := 40;
GreenED.Left := 40;
BlueED.Left := 40;
Caption := 'HSV Adjust';
RedS.Position := RegIniFile.ReadInteger('HSVAdjust','H',0);
GreenS.Position := RegIniFile.ReadInteger('HSVAdjust','S',0);
BlueS.Position := RegIniFile.ReadInteger('HSVAdjust','V',0);
end;
end;
RegIniFile.Free;
modi := False;
tft := TFPhoto(DPEMain.ActiveMDIChild);
tmpbmp := TBitmap.Create;
tmpbmp.PixelFormat := tft.Photo.Picture.Bitmap.PixelFormat;
hpal := tft.Photo.Picture.Bitmap.Palette;
tmpbmp.Palette := hpal;
tmpbmp.Width := tft.Photo.Picture.Width;
tmpbmp.Height := tft.Photo.Picture.Height;
tmpbmp.Canvas.Draw(0,0,tft.Photo.Picture.Bitmap);
end;
procedure TADCLRDLG.FormClose(Sender: TObject; var Action: TCloseAction);
begin
tmpbmp.Free;
end;
end.