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