Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /Unit1.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations) (download) (as text)
Wed Jul 15 23:11:42 2015 UTC (8 years, 8 months ago) by yamat0jp
File MIME type: text/x-pascal
File size: 3799 byte(s)
なんとかビットマプに対応
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 yamat0jp 2 s: TGraphic;
48     p: TPicture;
49 yamat0jp 1 i: Integer;
50     begin
51     if OpenPictureDialog1.Execute = true then
52     for i := 0 to OpenPictureDialog1.Files.Count - 1 do
53     begin
54 yamat0jp 2 if ExtractFileExt(OpenPictureDialog1.Files[i]) = '.png' then
55     s:=TPngImage.Create
56     else
57     begin
58     p:=TPicture.Create;
59     p.LoadFromFile(OpenPictureDialog1.FileName);
60     s:=p.Graphic;
61     end;
62 yamat0jp 1 s.LoadFromFile(OpenPictureDialog1.Files[i]);
63     List.Add(s);
64     Label2.Caption := IntToStr(List.Count);
65     Execute(UpDown1.Position);
66     end;
67     end;
68    
69     procedure TForm1.Button2Click(Sender: TObject);
70     var
71     i: Integer;
72     s: TBitmap;
73     begin
74     for i := 0 to List.Count - 1 do
75     TPngImage(List[i]).Free;
76     List.Clear;
77     Label2.Caption := '0';
78     s:=Image1.Picture.Bitmap;
79     s.Canvas.FillRect(Rect(0,0,s.Width,s.Height));
80     end;
81    
82     procedure TForm1.Button3Click(Sender: TObject);
83     begin
84     if SavePictureDialog1.Execute = true then
85     Image1.Picture.Bitmap.SaveToFile(SavePictureDialog1.FileName);
86     end;
87    
88     procedure TForm1.FormCreate(Sender: TObject);
89     begin
90     List := TList.Create;
91     end;
92    
93     procedure TForm1.FormDestroy(Sender: TObject);
94     begin
95     Button2Click(Sender);
96     List.Free;
97     end;
98    
99     procedure TForm1.UpDown1ChangingEx(Sender: TObject; var AllowChange: Boolean;
100     NewValue: Integer; Direction: TUpDownDirection);
101     var
102     n: integer;
103     begin
104     case Direction of
105     updUp:
106     n:=UpDown1.Position+UpDown1.Increment;
107     updDown:
108     n:=UpDown1.Position-UpDown1.Increment;
109     else
110     Exit;
111     end;
112     Execute(n);
113     end;
114    
115     procedure TForm1.Execute(aCount: integer);
116     var
117     i: Integer;
118 yamat0jp 2 s: TGraphic;
119 yamat0jp 1 bmp: TBitmap;
120     j: Integer;
121     k, m: Integer;
122     label label1;
123 yamat0jp 2 procedure Draw;
124     var
125     p: TPngImage;
126     t: TBitmap;
127     begin
128     if s is TPngImage then
129     (s as TPngImage).Draw(bmp.Canvas, Rect(i * s.Width, j * s.Height, (i + 1) * s.Width,
130     (j + 1) * s.Height))
131     else
132     begin
133     t:=TBitmap.Create;
134     t.Assign(s);
135     bmp.Canvas.Draw(i*s.Width,j*s.Height,t);
136     end;
137     end;
138 yamat0jp 1 begin
139     if List.Count = 0 then
140     Exit
141     else
142     s:=List[0];
143     m := List.Count div aCount;
144     bmp := TBitmap.Create;
145     try
146     bmp.Width := s.Width * m;
147     bmp.Height := s.Height * aCount;
148     k := 0;
149     for j := 0 to aCount-1 do
150     for i := 0 to m - 1 do
151     begin
152     if k <= List.Count - 1 then
153     begin
154     s := List[k];
155 yamat0jp 2 inc(k);
156 yamat0jp 1 end
157     else
158     goto label1;
159 yamat0jp 2 Draw;
160 yamat0jp 1 end;
161     label1:
162     Image1.Picture.Bitmap.Assign(bmp);
163     finally
164     bmp.Free;
165     end;
166     end;
167    
168     end.

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26