-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdlg_colors.pas
103 lines (78 loc) · 2.05 KB
/
dlg_colors.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
unit dlg_colors;
//Lazzy Image Viewer
//github.com/PascalVault
//License: GNU/GPL
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
ComCtrls, PV_Bitmap;
type
{ TColorsDlg }
TColorsDlg = class(TForm)
Button1: TButton;
Edit1: TEdit;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
RadioButton5: TRadioButton;
RadioButton6: TRadioButton;
RadioButton7: TRadioButton;
RadioGroup1: TRadioGroup;
UpDown1: TUpDown;
procedure Button1Click(Sender: TObject);
private
public
ColorMode: Integer;
procedure Show(Num: Integer); overload;
end;
var
ColorsDlg: TColorsDlg;
implementation
uses Unit1;
{$R *.lfm}
{ TColorsDlg }
procedure TColorsDlg.Button1Click(Sender: TObject);
var i: Integer;
ColorCount: Integer;
Dither: TDither;
begin
for i:=0 to GroupBox1.ControlCount - 1 do
if (GroupBox1.Controls[i] is TRadioButton) and TRadioButton(GroupBox1.Controls[i]).Checked then begin
ColorCount := GroupBox1.Controls[i].Tag;
break;
end;
if ColorCount = 1 then ColorCount := UpDown1.Position;
case RadioGroup1.ItemIndex of
0 : Dither := ddNone;
1 : Dither := ddFloyd;
2 : Dither := ddBurkes;
3 : Dither := ddStucki;
4 : Dither := ddJarvis;
5 : Dither := ddAtkinson;
6 : Dither := ddSierra2;
7 : Dither := ddSierra3;
8 : Dither := ddSierra4;
end;
Form1.SaveUndo;
if ColorMode = 256 then
Form1.GetBmp.ReduceColors(ColorCount-1, Dither)
else if ColorMode = -256 then
Form1.GetBmp.Grayscale(ColorCount-1, Dither)
else if ColorMode = 2 then
Form1.GetBmp.BlackWhite(Dither);
Form1.Redraw;
Close;
end;
procedure TColorsDlg.Show(Num: Integer);
begin
ColorMode := Num;
if Num = 2 then begin
RadioButton1.Checked := True;
end
else RadioButton5.Checked := True;
Show;
end;
end.