-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathunit7.pas
More file actions
121 lines (102 loc) · 2.67 KB
/
unit7.pas
File metadata and controls
121 lines (102 loc) · 2.67 KB
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
Unit Unit7;
{$MODE ObjFPC}{$H+}
Interface
Uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
Spin, LCLType, upixeleditor_types;
Type
{ TForm7 }
TForm7 = Class(TForm)
Button1: TButton;
Button2: TButton;
FloatSpinEdit1: TFloatSpinEdit;
Image1: TImage;
Label1: TLabel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Procedure FloatSpinEdit1Change(Sender: TObject);
Procedure FloatSpinEdit1KeyDown(Sender: TObject; Var Key: Word;
Shift: TShiftState);
Procedure FormCreate(Sender: TObject);
Procedure FormDestroy(Sender: TObject);
private
fInImage: TBitmap;
public
Procedure InitFromPixelArea(Const Data: TPixelArea);
Function GetScaleMode(): TScaleMode;
End;
Var
Form7: TForm7;
Implementation
{$R *.lfm}
Uses
IntfGraphics
, ugraphics
;
{ TForm7 }
Procedure TForm7.FormCreate(Sender: TObject);
Begin
caption := 'Rotation';
fInImage := TBitmap.Create;
End;
Procedure TForm7.FloatSpinEdit1Change(Sender: TObject);
Var
b: TBitmap;
mode: TInterpolationMode;
Begin
b := TBitmap.Create;
b.Assign(fInImage);
mode := imNearestNeighbour;
If RadioButton2.Checked Then mode := imBilinear;
RotateDegrees(b, FloatSpinEdit1.Value, mode);
Image1.Picture.Assign(b);
b.free;
End;
Procedure TForm7.FloatSpinEdit1KeyDown(Sender: TObject; Var Key: Word;
Shift: TShiftState);
Begin
If key = VK_RETURN Then button2.click;
End;
Procedure TForm7.FormDestroy(Sender: TObject);
Begin
fInImage.free;
fInImage := Nil;
End;
Procedure TForm7.InitFromPixelArea(Const Data: TPixelArea);
Var
i, j: Integer;
tmp: TLazIntfImage;
DestHandle, DestMaskHandle: HBitmap;
{$IFDEF LCLGTK3}
c: TRGBA;
{$ENDIF}
Begin
fInImage.Width := length(data);
fInImage.Height := length(data[0]);
tmp := TLazIntfImage.Create(0, 0);
tmp.LoadFromBitmap(fInImage.Handle, fInImage.MaskHandle);
For i := 0 To high(data) Do Begin
For j := 0 To high(data[i]) Do Begin
{$IFDEF LCLGTK3}
c := data[i, j];
c.A := 255 - c.a; // WTF: wo muss man das noch berücksichtigen ?
tmp.Colors[i, j] := RGBAToFPColor(c);
{$ELSE}
tmp.Colors[i, j] := RGBAToFPColor(data[i, j]);
{$ENDIF}
End;
End;
tmp.CreateBitmaps(DestHandle, DestMaskHandle, false);
fInImage.Handle := DestHandle;
fInImage.MaskHandle := DestMaskHandle;
tmp.free;
FloatSpinEdit1.Value := 0.0;
RadioButton1.Checked := true;
FloatSpinEdit1Change(Nil);
End;
Function TForm7.GetScaleMode: TScaleMode;
Begin
result := smScale;
If RadioButton2.Checked Then result := smSmoothScale;
End;
End.