-
Notifications
You must be signed in to change notification settings - Fork 2
/
unit1.pas
149 lines (131 loc) · 4.36 KB
/
unit1.pas
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
(******************************************************************************)
(* AVI_Creator ??.??.???? *)
(* *)
(* Version : 0.01 *)
(* *)
(* Author : Uwe Schächterle (Corpsman) *)
(* *)
(* Support : www.Corpsman.de *)
(* *)
(* Description : Demo that shows the usage of ugwavi.pas *)
(* *)
(* License : See the file license.md, located under: *)
(* https://github.com/PascalCorpsman/Software_Licenses/blob/main/license.md *)
(* for details about the license. *)
(* *)
(* It is not allowed to change or remove this text from any *)
(* source file of the project. *)
(* *)
(* Warranty : There is no warranty, neither in correctness of the *)
(* implementation, nor anything other that could happen *)
(* or go wrong, use at your own risk. *)
(* *)
(* Known Issues: none *)
(* *)
(* History : 0.01 - Initial version *)
(* *)
(******************************************************************************)
Unit Unit1;
{$MODE objfpc}{$H+}
Interface
Uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
Type
{ TForm1 }
TForm1 = Class(TForm)
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
SaveDialog1: TSaveDialog;
Procedure Button1Click(Sender: TObject);
Procedure FormCreate(Sender: TObject);
private
public
End;
Var
Form1: TForm1;
Implementation
{$R *.lfm}
Uses FileUtil, ugwavi;
Function LoadImg(Filename: String): TJPEGImage;
Var
bmp: Tbitmap;
png: TPortableNetworkGraphic;
Begin
result := TJPEGImage.Create;
Case lowercase(ExtractFileExt(Filename)) Of
'.bmp': Begin
bmp := TBitmap.Create;
bmp.LoadFromFile(Filename);
result.Assign(bmp);
bmp.free;
End;
'.jpg': Begin
result.LoadFromFile(Filename);
End;
'.png': Begin
png := TPortableNetworkGraphic.Create;
png.LoadFromFile(Filename);
result.Assign(png);
png.free;
End;
Else Begin
Raise exception.create('Error unknown filetype:' + Filename);
End;
End;
End;
{ TForm1 }
Procedure TForm1.Button1Click(Sender: TObject);
Var
Dir: String;
sl: TStringList;
avi: tgwavi;
jp: TJPEGImage;
m: TMemoryStream;
i: Integer;
Begin
If Not SelectDirectory(Dir, [], 0) Then Begin
exit;
End;
sl := findallFiles(dir, '*.bmp;*.png;*.jpg', false);
If sl.count = 0 Then Begin
showmessage('Error, no files found.');
sl.free;
exit;
End;
showmessage(inttostr(sl.count) + ' found.');
If Not SaveDialog1.Execute Then Begin
sl.free;
exit;
End;
sl.Sort;
jp := LoadImg(sl[0]);
avi := tgwavi.Create();
avi.Open(SaveDialog1.FileName, jp.Width, jp.Height, 'MJPG', strtointdef(Edit1.Text, 25), Nil);
m := TMemoryStream.Create;
jp.SaveToStream(m);
jp.free;
m.Position := 0;
avi.Add_Frame(m);
m.free;
For i := 1 To sl.Count - 1 Do Begin
jp := LoadImg(sl[i]);
m := TMemoryStream.Create;
jp.SaveToStream(m);
jp.free;
m.Position := 0;
avi.Add_Frame(m);
m.free;
End;
avi.Close;
avi.free;
sl.free;
showmessage('Done.');
End;
Procedure TForm1.FormCreate(Sender: TObject);
Begin
edit1.text := '25';
caption := 'Avi creater ver. 0.01';
End;
End.