-
Notifications
You must be signed in to change notification settings - Fork 0
/
CONUN.PAS
100 lines (85 loc) · 2.3 KB
/
CONUN.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
unit conun;
interface
uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
Buttons, ExtCtrls,Registry, ComCtrls;
type
TAContrastDLG = class(TForm)
OKBtn: TButton;
CancelBtn: TButton;
Bevel: TBevel;
PreviewBTN: TButton;
TrackBar: TTrackBar;
val: TLabel;
procedure TrackBarChange(Sender: TObject);
procedure PreviewBTNClick(Sender: TObject);
procedure CancelBtnClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
AContrastDLG: TAContrastDLG;
function ShowContraDLG(var value : integer) : integer;
implementation
{$R *.DFM}
uses dpemform,photo;
var tmpbmp : TBitmap;
modi : boolean;
tft : TFPhoto;
hpal : HPalette;
function ShowContraDLG(var value : integer) : integer;
begin
with TAContrastDLG.Create(Application) do
try
result := ShowModal;
if Result = mrOK then
begin
value := TrackBar.Position;
RegIniFile := TRegIniFile.Create(DPEIniName);
RegIniFile.WriteInteger('BC','Contrast',TrackBar.Position);
RegIniFile.Free;
end;
finally
Free;
end;
end;
procedure TAContrastDLG.TrackBarChange(Sender: TObject);
begin
val.Caption := IntToStr(TrackBar.Position) + '%';
end;
procedure TAContrastDLG.PreviewBTNClick(Sender: TObject);
begin
modi := True;
tmpbmp.Palette := hpal;
tft.Photo.Canvas.Draw(0,0,tmpbmp);
tft.ChangeContrast(Trackbar.Position,false);
end;
procedure TAContrastDLG.CancelBtnClick(Sender: TObject);
begin
if modi then tft.Photo.Picture.Bitmap.Assign(tmpbmp);
end;
procedure TAContrastDLG.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
tmpbmp.Free;
end;
procedure TAContrastDLG.FormCreate(Sender: TObject);
begin
RegIniFile := TRegIniFile.Create(DPEIniName);
TrackBar.Position := RegIniFile.ReadInteger('BC','Contrast',0);
RegIniFile.Free;
TrackBarChange(Sender);
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;
end.