| 1 |
yamat0jp |
1 |
unit Unit1; |
| 2 |
|
|
|
| 3 |
|
|
interface |
| 4 |
|
|
|
| 5 |
|
|
uses |
| 6 |
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, |
| 7 |
|
|
System.Classes, Vcl.Graphics, |
| 8 |
|
|
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtDlgs, Vcl.StdCtrls, Vcl.ExtCtrls, |
| 9 |
|
|
Vcl.ComCtrls, Vcl.Imaging.pngImage; |
| 10 |
|
|
|
| 11 |
|
|
type |
| 12 |
|
|
TForm1 = class(TForm) |
| 13 |
|
|
Image1: TImage; |
| 14 |
|
|
Button1: TButton; |
| 15 |
|
|
OpenPictureDialog1: TOpenPictureDialog; |
| 16 |
|
|
Edit1: TEdit; |
| 17 |
|
|
UpDown1: TUpDown; |
| 18 |
|
|
Label1: TLabel; |
| 19 |
|
|
Button2: TButton; |
| 20 |
|
|
Label2: TLabel; |
| 21 |
|
|
Button3: TButton; |
| 22 |
|
|
SavePictureDialog1: TSavePictureDialog; |
| 23 |
|
|
procedure Button1Click(Sender: TObject); |
| 24 |
|
|
procedure FormCreate(Sender: TObject); |
| 25 |
|
|
procedure FormDestroy(Sender: TObject); |
| 26 |
|
|
procedure Button2Click(Sender: TObject); |
| 27 |
|
|
procedure Button3Click(Sender: TObject); |
| 28 |
|
|
procedure UpDown1ChangingEx(Sender: TObject; var AllowChange: Boolean; |
| 29 |
|
|
NewValue: Integer; Direction: TUpDownDirection); |
| 30 |
|
|
private |
| 31 |
|
|
procedure Execute(aCount: integer); |
| 32 |
|
|
{ Private éž } |
| 33 |
|
|
public |
| 34 |
|
|
{ Public éž } |
| 35 |
|
|
List: TList; |
| 36 |
|
|
end; |
| 37 |
|
|
|
| 38 |
|
|
var |
| 39 |
|
|
Form1: TForm1; |
| 40 |
|
|
|
| 41 |
|
|
implementation |
| 42 |
|
|
|
| 43 |
|
|
{$R *.dfm} |
| 44 |
|
|
|
| 45 |
|
|
procedure TForm1.Button1Click(Sender: TObject); |
| 46 |
|
|
var |
| 47 |
|
|
s: TPngImage; |
| 48 |
|
|
i: Integer; |
| 49 |
|
|
begin |
| 50 |
|
|
if OpenPictureDialog1.Execute = true then |
| 51 |
|
|
for i := 0 to OpenPictureDialog1.Files.Count - 1 do |
| 52 |
|
|
begin |
| 53 |
|
|
s := TPngImage.Create; |
| 54 |
|
|
s.LoadFromFile(OpenPictureDialog1.Files[i]); |
| 55 |
|
|
List.Add(s); |
| 56 |
|
|
Label2.Caption := IntToStr(List.Count); |
| 57 |
|
|
Execute(UpDown1.Position); |
| 58 |
|
|
end; |
| 59 |
|
|
end; |
| 60 |
|
|
|
| 61 |
|
|
procedure TForm1.Button2Click(Sender: TObject); |
| 62 |
|
|
var |
| 63 |
|
|
i: Integer; |
| 64 |
|
|
s: TBitmap; |
| 65 |
|
|
begin |
| 66 |
|
|
for i := 0 to List.Count - 1 do |
| 67 |
|
|
TPngImage(List[i]).Free; |
| 68 |
|
|
List.Clear; |
| 69 |
|
|
Label2.Caption := '0'; |
| 70 |
|
|
s:=Image1.Picture.Bitmap; |
| 71 |
|
|
s.Canvas.FillRect(Rect(0,0,s.Width,s.Height)); |
| 72 |
|
|
end; |
| 73 |
|
|
|
| 74 |
|
|
procedure TForm1.Button3Click(Sender: TObject); |
| 75 |
|
|
begin |
| 76 |
|
|
if SavePictureDialog1.Execute = true then |
| 77 |
|
|
Image1.Picture.Bitmap.SaveToFile(SavePictureDialog1.FileName); |
| 78 |
|
|
end; |
| 79 |
|
|
|
| 80 |
|
|
procedure TForm1.FormCreate(Sender: TObject); |
| 81 |
|
|
begin |
| 82 |
|
|
List := TList.Create; |
| 83 |
|
|
end; |
| 84 |
|
|
|
| 85 |
|
|
procedure TForm1.FormDestroy(Sender: TObject); |
| 86 |
|
|
begin |
| 87 |
|
|
Button2Click(Sender); |
| 88 |
|
|
List.Free; |
| 89 |
|
|
end; |
| 90 |
|
|
|
| 91 |
|
|
procedure TForm1.UpDown1ChangingEx(Sender: TObject; var AllowChange: Boolean; |
| 92 |
|
|
NewValue: Integer; Direction: TUpDownDirection); |
| 93 |
|
|
var |
| 94 |
|
|
n: integer; |
| 95 |
|
|
begin |
| 96 |
|
|
case Direction of |
| 97 |
|
|
updUp: |
| 98 |
|
|
n:=UpDown1.Position+UpDown1.Increment; |
| 99 |
|
|
updDown: |
| 100 |
|
|
n:=UpDown1.Position-UpDown1.Increment; |
| 101 |
|
|
else |
| 102 |
|
|
Exit; |
| 103 |
|
|
end; |
| 104 |
|
|
Execute(n); |
| 105 |
|
|
end; |
| 106 |
|
|
|
| 107 |
|
|
procedure TForm1.Execute(aCount: integer); |
| 108 |
|
|
var |
| 109 |
|
|
i: Integer; |
| 110 |
|
|
s: TPngImage; |
| 111 |
|
|
bmp: TBitmap; |
| 112 |
|
|
j: Integer; |
| 113 |
|
|
k, m: Integer; |
| 114 |
|
|
label label1; |
| 115 |
|
|
begin |
| 116 |
|
|
if List.Count = 0 then |
| 117 |
|
|
Exit |
| 118 |
|
|
else |
| 119 |
|
|
s:=List[0]; |
| 120 |
|
|
m := List.Count div aCount; |
| 121 |
|
|
bmp := TBitmap.Create; |
| 122 |
|
|
try |
| 123 |
|
|
bmp.Width := s.Width * m; |
| 124 |
|
|
bmp.Height := s.Height * aCount; |
| 125 |
|
|
k := 0; |
| 126 |
|
|
for j := 0 to aCount-1 do |
| 127 |
|
|
for i := 0 to m - 1 do |
| 128 |
|
|
begin |
| 129 |
|
|
if k <= List.Count - 1 then |
| 130 |
|
|
begin |
| 131 |
|
|
s := List[k]; |
| 132 |
|
|
inc(k) |
| 133 |
|
|
end |
| 134 |
|
|
else |
| 135 |
|
|
goto label1; |
| 136 |
|
|
s.Draw(bmp.Canvas, Rect(i * s.Width, j * s.Height, (i + 1) * s.Width, |
| 137 |
|
|
(j + 1) * s.Height)); |
| 138 |
|
|
end; |
| 139 |
|
|
label1: |
| 140 |
|
|
Image1.Picture.Bitmap.Assign(bmp); |
| 141 |
|
|
finally |
| 142 |
|
|
bmp.Free; |
| 143 |
|
|
end; |
| 144 |
|
|
end; |
| 145 |
|
|
|
| 146 |
|
|
end. |