Rev 7190 | Rev 7227 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7190 | Rev 7224 | ||
---|---|---|---|
Line 91... | Line 91... | ||
91 | #define Image_bpp2i 8 |
91 | #define Image_bpp2i 8 |
92 | #define Image_bpp4i 9 |
92 | #define Image_bpp4i 9 |
93 | #define Image_bpp8a 10 // grayscale with alpha channel; application layer only!!! kernel doesn't handle this image type, libimg can only create and destroy such images |
93 | #define Image_bpp8a 10 // grayscale with alpha channel; application layer only!!! kernel doesn't handle this image type, libimg can only create and destroy such images |
Line 94... | Line 94... | ||
94 | 94 | ||
95 | 95 | ||
96 | dword load_image(dword filename) |
96 | :dword load_image(dword filename) |
97 | { |
97 | { |
98 | //align 4 |
98 | //align 4 |
99 | dword img_data=0; |
99 | dword img_data=0; |
Line 166... | Line 166... | ||
166 | mem_Free(img_data); |
166 | mem_Free(img_data); |
167 | $stc |
167 | $stc |
168 | return 0; |
168 | return 0; |
169 | } |
169 | } |
Line -... | Line 170... | ||
- | 170 | ||
- | 171 | :dword create_image(dword type, dword width, dword height) { |
|
- | 172 | img_create stdcall(width, height, type); |
|
- | 173 | return EAX; |
|
- | 174 | } |
|
- | 175 | ||
- | 176 | // size - output parameter, error code / the size of encoded data |
|
- | 177 | :dword encode_image(dword image_ptr, dword options, dword specific_options, dword* size) { |
|
- | 178 | img_encode stdcall(image_ptr, options, specific_options); |
|
- | 179 | ESDWORD[size] = ECX; |
|
- | 180 | ||
- | 181 | return EAX; |
|
- | 182 | } |
|
170 | 183 | ||
171 | void DrawLibImage(dword image_pointer,x,y,w,h,offx,offy) { |
184 | :void DrawLibImage(dword image_pointer,x,y,w,h,offx,offy) { |
172 | img_draw stdcall ( |
185 | img_draw stdcall ( |
173 | image_pointer, |
186 | image_pointer, |
174 | x, |
187 | x, |
175 | y, |
188 | y, |
Line 178... | Line 191... | ||
178 | offx, |
191 | offx, |
179 | offy |
192 | offy |
180 | ); |
193 | ); |
181 | } |
194 | } |
Line -... | Line 195... | ||
- | 195 | ||
182 | 196 | //NOTICE: DO NOT FORGOT TO INIT libio AND libimg!!! |
|
- | 197 | :void save_image(dword _image, _w, _h, _path) |
|
183 | dword create_image(dword type, dword width, dword height) { |
198 | { |
- | 199 | char save_success_message[4096+200]; |
|
- | 200 | dword encoded_data=0; |
|
184 | img_create stdcall(width, height, type); |
201 | dword encoded_size=0; |
- | 202 | dword image_ptr = 0; |
|
- | 203 | ||
- | 204 | image_ptr = create_image(Image_bpp24, _w, _h); |
|
- | 205 | ||
- | 206 | if (image_ptr == 0) { |
|
185 | return EAX; |
207 | notify("'Error saving file, probably not enought memory!' -E"); |
- | 208 | } |
|
- | 209 | else { |
|
- | 210 | EDI = image_ptr; |
|
Line 186... | Line -... | ||
186 | } |
- | |
187 | 211 | memmov(EDI._Image.Data, _image, _w * _h * 3); |
|
188 | // size - output parameter, error code / the size of encoded data |
- | |
189 | dword encode_image(dword image_ptr, dword options, dword specific_options, dword* size) { |
- | |
Line -... | Line 212... | ||
- | 212 | ||
- | 213 | encoded_data = encode_image(image_ptr, LIBIMG_FORMAT_PNG, 0, #encoded_size); |
|
190 | img_encode stdcall(image_ptr, options, specific_options); |
214 | |
- | 215 | img_destroy stdcall(image_ptr); |
|
191 | ESDWORD[size] = ECX; |
216 | |
- | 217 | if(encoded_data == 0) { |
|
- | 218 | notify("'Error saving file, incorrect data!' -E"); |
|
- | 219 | } |
|
- | 220 | else { |
|
- | 221 | if (WriteFile(encoded_size, encoded_data, _path) == 0) { |
|
- | 222 | sprintf(#save_success_message, "'File saved as %s' -O", _path); |
|
- | 223 | notify(#save_success_message); |
|
- | 224 | } |
|
- | 225 | else { |
|
- | 226 | notify("'Error saving file! Probably not enought space or file system is not writable!' -E"); |
|
- | 227 | } |
|
- | 228 | } |
|
Line 192... | Line 229... | ||
192 | 229 | } |
|
193 | return EAX; |
230 | } |