source: trunk/Packages/bgracontrols/9slicescaling/unit1.pas

Last change on this file was 2, checked in by chronos, 5 years ago
File size: 3.2 KB
Line 
1unit Unit1;
2
3{$mode objfpc}{$H+}
4
5interface
6
7uses
8 Forms, Spin, ExtCtrls, StdCtrls, BGRAVirtualScreen, BGRABitmap, BGRASliceScaling, Classes,
9 BGRABitmapTypes;
10
11type
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
42var
43 Form1: TForm1;
44
45implementation
46
47uses Types;
48
49{ TForm1 }
50
51procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
52begin
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);
64end;
65
66procedure TForm1.CheckBox_RepeatChange(Sender: TObject);
67begin
68 if not initializing then BGRAVirtualScreen1.RedrawBitmap;
69end;
70
71procedure TForm1.FormCreate(Sender: TObject);
72begin
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;
86end;
87
88procedure TForm1.FormDestroy(Sender: TObject);
89begin
90 sliceScaling.Free;
91end;
92
93procedure TForm1.SpinEditChange(Sender: TObject);
94begin
95 if not initializing then BGRAVirtualScreen1.RedrawBitmap;
96end;
97
98{$R *.lfm}
99
100end.
Note: See TracBrowser for help on using the repository browser.