1 | unit Unit1;
|
---|
2 |
|
---|
3 | {$mode objfpc}{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Forms, Spin, ExtCtrls, StdCtrls, BGRAVirtualScreen, BGRABitmap, BGRASliceScaling, Classes,
|
---|
9 | BGRABitmapTypes;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TForm1 }
|
---|
14 |
|
---|
15 | TForm1 = class(TForm)
|
---|
16 | BGRAVirtualScreen1: TBGRAVirtualScreen;
|
---|
17 | CheckBox1: TCheckBox;
|
---|
18 | CheckBox_RepeatMiddleHoriz: TCheckBox;
|
---|
19 | CheckBox_RepeatMiddleVert: TCheckBox;
|
---|
20 | CheckBox_RepeatTop: TCheckBox;
|
---|
21 | CheckBox_RepeatRight: TCheckBox;
|
---|
22 | CheckBox_RepeatLeft: TCheckBox;
|
---|
23 | CheckBox_RepeatBottom: TCheckBox;
|
---|
24 | Image2: TImage;
|
---|
25 | SpinEdit1: TSpinEdit;
|
---|
26 | SpinEdit2: TSpinEdit;
|
---|
27 | SpinEdit3: TSpinEdit;
|
---|
28 | SpinEdit4: TSpinEdit;
|
---|
29 | procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
|
---|
30 | procedure CheckBox_RepeatChange(Sender: TObject);
|
---|
31 | procedure FormCreate(Sender: TObject);
|
---|
32 | procedure FormDestroy(Sender: TObject);
|
---|
33 | procedure SpinEditChange(Sender: TObject);
|
---|
34 | private
|
---|
35 | { private declarations }
|
---|
36 | public
|
---|
37 | { public declarations }
|
---|
38 | sliceScaling: TBGRASliceScaling;
|
---|
39 | initializing: boolean;
|
---|
40 | end;
|
---|
41 |
|
---|
42 | var
|
---|
43 | Form1: TForm1;
|
---|
44 |
|
---|
45 | implementation
|
---|
46 |
|
---|
47 | uses Types;
|
---|
48 |
|
---|
49 | { TForm1 }
|
---|
50 |
|
---|
51 | procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
|
---|
52 | begin
|
---|
53 | sliceScaling.ResampleMode := rmSimpleStretch;
|
---|
54 | sliceScaling.SliceRepeat[srpTop] := CheckBox_RepeatTop.Checked;
|
---|
55 | sliceScaling.SliceRepeat[srpLeft] := CheckBox_RepeatLeft.Checked;
|
---|
56 | sliceScaling.SliceRepeat[srpRight] := CheckBox_RepeatRight.Checked;
|
---|
57 | sliceScaling.SliceRepeat[srpBottom] := CheckBox_RepeatBottom.Checked;
|
---|
58 | sliceScaling.SliceRepeat[srpMiddleHorizontal] := CheckBox_RepeatMiddleHoriz.Checked;
|
---|
59 | sliceScaling.SliceRepeat[srpMiddleVertical] := CheckBox_RepeatMiddleVert.Checked;
|
---|
60 | sliceScaling.SetMargins(SpinEdit1.Value,SpinEdit2.Value,SpinEdit3.Value,SpinEdit4.Value);
|
---|
61 | sliceScaling.Draw(Bitmap, rect(0,0,Bitmap.Width,Bitmap.Height), CheckBox1.Checked);
|
---|
62 | sliceScaling.Draw(Bitmap, rect(0,0,Bitmap.Width div 2,Bitmap.Height div 2), CheckBox1.Checked);
|
---|
63 | sliceScaling.Draw(Bitmap, rect(Bitmap.Width*3 div 4,Bitmap.Height*3 div 4,Bitmap.Width,Bitmap.Height), CheckBox1.Checked);
|
---|
64 | end;
|
---|
65 |
|
---|
66 | procedure TForm1.CheckBox_RepeatChange(Sender: TObject);
|
---|
67 | begin
|
---|
68 | if not initializing then BGRAVirtualScreen1.RedrawBitmap;
|
---|
69 | end;
|
---|
70 |
|
---|
71 | procedure TForm1.FormCreate(Sender: TObject);
|
---|
72 | begin
|
---|
73 | initializing := true;
|
---|
74 | sliceScaling := TBGRASliceScaling.Create(Image2.Picture.Bitmap,
|
---|
75 | SpinEdit1.Value, SpinEdit2.Value, SpinEdit3.Value, SpinEdit4.Value);
|
---|
76 | sliceScaling.AutodetectRepeat;
|
---|
77 |
|
---|
78 | CheckBox_RepeatTop.Checked := sliceScaling.SliceRepeat[srpTop];
|
---|
79 | CheckBox_RepeatLeft.Checked := sliceScaling.SliceRepeat[srpLeft];
|
---|
80 | CheckBox_RepeatRight.Checked := sliceScaling.SliceRepeat[srpRight];
|
---|
81 | CheckBox_RepeatBottom.Checked := sliceScaling.SliceRepeat[srpBottom];
|
---|
82 | CheckBox_RepeatMiddleHoriz.Checked := sliceScaling.SliceRepeat[srpMiddleHorizontal];
|
---|
83 | CheckBox_RepeatMiddleVert.Checked := sliceScaling.SliceRepeat[srpMiddleVertical];
|
---|
84 |
|
---|
85 | initializing := false;
|
---|
86 | end;
|
---|
87 |
|
---|
88 | procedure TForm1.FormDestroy(Sender: TObject);
|
---|
89 | begin
|
---|
90 | sliceScaling.Free;
|
---|
91 | end;
|
---|
92 |
|
---|
93 | procedure TForm1.SpinEditChange(Sender: TObject);
|
---|
94 | begin
|
---|
95 | if not initializing then BGRAVirtualScreen1.RedrawBitmap;
|
---|
96 | end;
|
---|
97 |
|
---|
98 | {$R *.lfm}
|
---|
99 |
|
---|
100 | end.
|
---|