Rev 2685 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2685 | Rev 3014 | ||
---|---|---|---|
1 | use32 |
1 | use32 |
2 | org 0x0 |
2 | org 0x0 |
3 | 3 | ||
4 | db 'MENUET01' |
4 | db 'MENUET01' |
5 | dd 0x01, START, I_END, 0x1000, 0x1000, 0, 0 |
5 | dd 0x01, START, I_END, 0x1000, 0x1000, 0, 0 |
6 | 6 | ||
7 | ;----------------------------------------------------------------------------- |
7 | ;----------------------------------------------------------------------------- |
8 | 8 | ||
9 | include '../../../../../proc32.inc' |
9 | include '../../../../../proc32.inc' |
10 | include '../../../../../macros.inc' |
10 | include '../../../../../macros.inc' |
11 | include '../dll.inc' |
11 | include '../../../../../dll.inc' |
12 | 12 | ||
13 | include '../../libio/libio.inc' |
13 | include '../../libio/libio.inc' |
14 | include '../../libimg/libimg.inc' |
14 | include '../../libimg/libimg.inc' |
15 | 15 | ||
16 | ;----------------------------------------------------------------------------- |
16 | ;----------------------------------------------------------------------------- |
17 | 17 | ||
18 | START: |
18 | START: |
19 | mcall 68, 11 |
19 | mcall 68, 11 |
20 | 20 | ||
21 | stdcall dll.Load, @IMPORT |
21 | stdcall dll.Load, @IMPORT |
22 | or eax, eax |
22 | or eax, eax |
23 | jnz exit |
23 | jnz exit |
24 | 24 | ||
25 | invoke file.open, input_file, O_READ |
25 | invoke file.open, input_file, O_READ |
26 | or eax, eax |
26 | or eax, eax |
27 | jz exit |
27 | jz exit |
28 | mov [fh], eax |
28 | mov [fh], eax |
29 | 29 | ||
30 | invoke file.size, input_file |
30 | invoke file.size, input_file |
31 | mov [img_data_len], ebx |
31 | mov [img_data_len], ebx |
32 | stdcall mem.Alloc, ebx |
32 | stdcall mem.Alloc, ebx |
33 | or eax, eax |
33 | or eax, eax |
34 | jz exit |
34 | jz exit |
35 | mov [img_data], eax |
35 | mov [img_data], eax |
36 | 36 | ||
37 | invoke file.read, [fh], eax, [img_data_len] |
37 | invoke file.read, [fh], eax, [img_data_len] |
38 | cmp eax, -1 |
38 | cmp eax, -1 |
39 | je exit |
39 | je exit |
40 | cmp eax, [img_data_len] |
40 | cmp eax, [img_data_len] |
41 | jne exit |
41 | jne exit |
42 | 42 | ||
43 | invoke file.close, [fh] |
43 | invoke file.close, [fh] |
44 | inc eax |
44 | inc eax |
45 | jz exit |
45 | jz exit |
46 | 46 | ||
47 | invoke img.decode, [img_data], [img_data_len], 0 |
47 | invoke img.decode, [img_data], [img_data_len], 0 |
48 | or eax, eax |
48 | or eax, eax |
49 | jz exit |
49 | jz exit |
50 | mov [image_initial], eax |
50 | mov [image_initial], eax |
51 | 51 | ||
52 | stdcall mem.Free, [img_data] |
52 | stdcall mem.Free, [img_data] |
53 | test eax, eax |
53 | test eax, eax |
54 | jz exit |
54 | jz exit |
55 | 55 | ||
56 | ;----------------------------------------------------------------------------- |
56 | ;----------------------------------------------------------------------------- |
57 | 57 | ||
58 | mov eax, [image_initial] |
58 | mov eax, [image_initial] |
59 | stdcall [img.create], [eax + Image.Width], [eax + Image.Height], Image.bpp24 |
59 | stdcall [img.create], [eax + Image.Width], [eax + Image.Height], Image.bpp24 |
60 | test eax, eax |
60 | test eax, eax |
61 | jz exit |
61 | jz exit |
62 | mov [image_to_rgb2] ,eax |
62 | mov [image_to_rgb2] ,eax |
63 | stdcall [img.to_rgb2], [image_initial], [eax + Image.Data] |
63 | stdcall [img.to_rgb2], [image_initial], [eax + Image.Data] |
64 | 64 | ||
65 | mov eax, [image_to_rgb2] |
65 | mov eax, [image_to_rgb2] |
66 | mov esi, [eax + Image.Data] |
66 | mov esi, [eax + Image.Data] |
67 | mov edi, esi |
67 | mov edi, esi |
68 | mov ecx, [eax + Image.Width] |
68 | mov ecx, [eax + Image.Width] |
69 | imul ecx, [eax + Image.Height] |
69 | imul ecx, [eax + Image.Height] |
70 | lea ecx, [ecx*3] |
70 | lea ecx, [ecx*3] |
71 | @@: |
71 | @@: |
72 | lodsb |
72 | lodsb |
73 | not al |
73 | not al |
74 | stosb |
74 | stosb |
75 | dec ecx |
75 | dec ecx |
76 | jnz @b |
76 | jnz @b |
77 | 77 | ||
78 | stdcall [img.encode], [image_to_rgb2], (LIBIMG_FORMAT_ID_PNM), 0 |
78 | stdcall [img.encode], [image_to_rgb2], (LIBIMG_FORMAT_ID_PNM), 0 |
79 | ; stdcall [img.encode], [image_initial], (LIBIMG_FORMAT_ID_PNM), 0 |
79 | ; stdcall [img.encode], [image_initial], (LIBIMG_FORMAT_ID_PNM), 0 |
80 | test eax, eax |
80 | test eax, eax |
81 | jz exit |
81 | jz exit |
82 | mov [encoded_file], eax |
82 | mov [encoded_file], eax |
83 | mov [encoded_file_size], ecx |
83 | mov [encoded_file_size], ecx |
84 | 84 | ||
85 | invoke file.open, output_file, O_WRITE OR O_CREATE |
85 | invoke file.open, output_file, O_WRITE OR O_CREATE |
86 | or eax, eax |
86 | or eax, eax |
87 | jz exit |
87 | jz exit |
88 | mov [fh], eax |
88 | mov [fh], eax |
89 | 89 | ||
90 | invoke file.write, [fh], [encoded_file], [encoded_file_size] |
90 | invoke file.write, [fh], [encoded_file], [encoded_file_size] |
91 | cmp eax, [encoded_file_size] |
91 | cmp eax, [encoded_file_size] |
92 | jne exit |
92 | jne exit |
93 | 93 | ||
94 | invoke file.close, [fh] |
94 | invoke file.close, [fh] |
95 | inc eax |
95 | inc eax |
96 | jz exit |
96 | jz exit |
97 | 97 | ||
98 | stdcall mem.Free, [encoded_file] |
98 | stdcall mem.Free, [encoded_file] |
99 | ;----------------------------------------------------------------------------- |
99 | ;----------------------------------------------------------------------------- |
100 | 100 | ||
101 | redraw: |
101 | redraw: |
102 | call draw_window |
102 | call draw_window |
103 | 103 | ||
104 | still: |
104 | still: |
105 | mcall 10 |
105 | mcall 10 |
106 | cmp eax, 1 |
106 | cmp eax, 1 |
107 | je redraw |
107 | je redraw |
108 | cmp eax, 2 |
108 | cmp eax, 2 |
109 | je key |
109 | je key |
110 | cmp eax, 3 |
110 | cmp eax, 3 |
111 | je button |
111 | je button |
112 | jmp still |
112 | jmp still |
113 | 113 | ||
114 | key: |
114 | key: |
115 | mcall 2 |
115 | mcall 2 |
116 | jmp still |
116 | jmp still |
117 | 117 | ||
118 | button: |
118 | button: |
119 | mcall 17 |
119 | mcall 17 |
120 | shr eax, 8 |
120 | shr eax, 8 |
121 | 121 | ||
122 | cmp eax, 1 |
122 | cmp eax, 1 |
123 | jne still |
123 | jne still |
124 | 124 | ||
125 | exit: |
125 | exit: |
126 | cmp [image_initial], 0 |
126 | cmp [image_initial], 0 |
127 | je @f |
127 | je @f |
128 | stdcall [img.destroy], [image_initial] |
128 | stdcall [img.destroy], [image_initial] |
129 | @@: |
129 | @@: |
130 | cmp [image_to_rgb2], 0 |
130 | cmp [image_to_rgb2], 0 |
131 | je @f |
131 | je @f |
132 | stdcall [img.destroy], [image_to_rgb2] |
132 | stdcall [img.destroy], [image_to_rgb2] |
133 | @@: |
133 | @@: |
134 | mcall -1 |
134 | mcall -1 |
135 | 135 | ||
136 | 136 | ||
137 | draw_window: |
137 | draw_window: |
138 | mcall 12, 1 |
138 | mcall 12, 1 |
139 | mcall 0, <100, 388>, <100, 350>, 0x33FFFFFF, , window_title |
139 | mcall 0, <100, 388>, <100, 350>, 0x33FFFFFF, , window_title |
140 | 140 | ||
141 | mov eax, [image_initial] |
141 | mov eax, [image_initial] |
142 | stdcall [img.draw], eax, 0, 0, [eax + Image.Width], [eax + Image.Height], 0, 0 |
142 | stdcall [img.draw], eax, 0, 0, [eax + Image.Width], [eax + Image.Height], 0, 0 |
143 | 143 | ||
144 | mov eax, [image_to_rgb2] |
144 | mov eax, [image_to_rgb2] |
145 | stdcall [img.draw], eax, 0, [eax + Image.Height], [eax + Image.Width], [eax + Image.Height], 0, 0 |
145 | stdcall [img.draw], eax, 0, [eax + Image.Height], [eax + Image.Width], [eax + Image.Height], 0, 0 |
146 | 146 | ||
147 | mcall 12, 2 |
147 | mcall 12, 2 |
148 | ret |
148 | ret |
149 | - | ||
150 | ;----------------------------------------------------------------------------- |
- | |
151 | proc mem.Alloc, size ;//////////////////////////////////////////////////////// |
- | |
152 | ;----------------------------------------------------------------------------- |
- | |
153 | push ebx ecx |
- | |
154 | mov ecx, [size] |
- | |
155 | add ecx, 4 |
- | |
156 | mcall 68, 12 |
- | |
157 | add ecx, -4 |
- | |
158 | mov [eax], ecx |
- | |
159 | add eax, 4 |
- | |
160 | pop ecx ebx |
- | |
161 | ret |
- | |
162 | endp |
- | |
163 | - | ||
164 | ;----------------------------------------------------------------------------- |
- | |
165 | proc mem.ReAlloc, mptr, size ;//////////////////////////////////////////////// |
- | |
166 | ;----------------------------------------------------------------------------- |
- | |
167 | push ebx ecx edx |
- | |
168 | mov ecx, [size] |
- | |
169 | or ecx, ecx |
- | |
170 | jz @f |
- | |
171 | add ecx, 4 |
- | |
172 | @@: mov edx, [mptr] |
- | |
173 | or edx, edx |
- | |
174 | jz @f |
- | |
175 | add edx, -4 |
- | |
176 | @@: mcall 68, 20 |
- | |
177 | or eax, eax |
- | |
178 | jz @f |
- | |
179 | add ecx, -4 |
- | |
180 | mov [eax], ecx |
- | |
181 | add eax, 4 |
- | |
182 | @@: pop edx ecx ebx |
- | |
183 | ret |
- | |
184 | endp |
- | |
185 | - | ||
186 | ;----------------------------------------------------------------------------- |
- | |
187 | proc mem.Free, mptr ;///////////////////////////////////////////////////////// |
- | |
188 | ;----------------------------------------------------------------------------- |
- | |
189 | push ebx ecx |
- | |
190 | mov ecx, [mptr] |
- | |
191 | or ecx, ecx |
- | |
192 | jz @f |
- | |
193 | add ecx, -4 |
- | |
194 | @@: mcall 68, 13 |
- | |
195 | pop ecx ebx |
- | |
196 | ret |
- | |
197 | endp |
- | |
198 | 149 | ||
199 | ;----------------------------------------------------------------------------- |
150 | ;----------------------------------------------------------------------------- |
200 | 151 | ||
201 | window_title db 'libimg to_rgb2 & encode demo',0 |
152 | window_title db 'libimg to_rgb2 & encode demo',0 |
202 | 153 | ||
203 | ;input_file db '/hd0/1/in_1bpp.wbmp',0 |
154 | ;input_file db '/hd0/1/in_1bpp.wbmp',0 |
204 | ;input_file db '/hd0/1/in_8bpp.tiff',0 |
155 | ;input_file db '/hd0/1/in_8bpp.tiff',0 |
205 | input_file db '/hd0/1/in_32bpp.png',0 |
156 | input_file db '/hd0/1/in_32bpp.png',0 |
206 | 157 | ||
207 | ;output_file db '/hd0/1/out_1bpp.pnm',0 |
158 | ;output_file db '/hd0/1/out_1bpp.pnm',0 |
208 | ;output_file db '/hd0/1/out_8bpp.pnm',0 |
159 | ;output_file db '/hd0/1/out_8bpp.pnm',0 |
209 | output_file db '/hd0/1/out_24bpp.pnm',0 |
160 | output_file db '/hd0/1/out_24bpp.pnm',0 |
210 | ;----------------------------------------------------------------------------- |
161 | ;----------------------------------------------------------------------------- |
211 | 162 | ||
212 | align 16 |
163 | align 16 |
213 | @IMPORT: |
164 | @IMPORT: |
214 | 165 | ||
215 | library \ |
166 | library \ |
216 | libio , 'libio.obj' , \ |
167 | libio , 'libio.obj' , \ |
217 | libimg , 'libimg.obj' |
168 | libimg , 'libimg.obj' |
218 | 169 | ||
219 | import libio , \ |
170 | import libio , \ |
220 | libio.init , 'lib_init' , \ |
171 | libio.init , 'lib_init' , \ |
221 | file.size , 'file_size' , \ |
172 | file.size , 'file_size' , \ |
222 | file.open , 'file_open' , \ |
173 | file.open , 'file_open' , \ |
223 | file.read , 'file_read' , \ |
174 | file.read , 'file_read' , \ |
224 | file.write , 'file_write' , \ |
175 | file.write , 'file_write' , \ |
225 | file.close , 'file_close' |
176 | file.close , 'file_close' |
226 | 177 | ||
227 | import libimg , \ |
178 | import libimg , \ |
228 | libimg.init , 'lib_init' , \ |
179 | libimg.init , 'lib_init' , \ |
229 | img.draw , 'img_draw' , \ |
180 | img.draw , 'img_draw' , \ |
230 | img.decode , 'img_decode' , \ |
181 | img.decode , 'img_decode' , \ |
231 | img.encode , 'img_encode' , \ |
182 | img.encode , 'img_encode' , \ |
232 | img.create , 'img_create' , \ |
183 | img.create , 'img_create' , \ |
233 | img.destroy , 'img_destroy', \ |
184 | img.destroy , 'img_destroy', \ |
234 | img.to_rgb2 , 'img_to_rgb2', \ |
185 | img.to_rgb2 , 'img_to_rgb2', \ |
235 | img.formats_table, 'img_formats_table' |
186 | img.formats_table, 'img_formats_table' |
236 | 187 | ||
237 | ;----------------------------------------------------------------------------- |
188 | ;----------------------------------------------------------------------------- |
238 | 189 | ||
239 | I_END: |
190 | I_END: |
240 | 191 | ||
241 | img_data dd ? |
192 | img_data dd ? |
242 | img_data_len dd ? |
193 | img_data_len dd ? |
243 | fh dd ? |
194 | fh dd ? |
244 | 195 | ||
245 | image_initial dd ? |
196 | image_initial dd ? |
246 | image_to_rgb2 dd ? |
197 | image_to_rgb2 dd ? |
247 | 198 | ||
248 | encoded_file dd ? |
199 | encoded_file dd ? |
249 | encoded_file_size dd ?100,>100,> |
200 | encoded_file_size dd ?100,>100,> |