Rev 7977 | Rev 8013 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7977 | Rev 7995 | ||
---|---|---|---|
Line 64... | Line 64... | ||
64 | #define LIBIMG_FORMAT_PNM 11 |
64 | #define LIBIMG_FORMAT_PNM 11 |
65 | #define LIBIMG_FORMAT_WBMP 12 |
65 | #define LIBIMG_FORMAT_WBMP 12 |
66 | #define LIBIMG_FORMAT_XBM 13 |
66 | #define LIBIMG_FORMAT_XBM 13 |
67 | #define LIBIMG_FORMAT_Z80 14 |
67 | #define LIBIMG_FORMAT_Z80 14 |
Line 68... | Line -... | ||
68 | - | ||
69 | struct _Image |
- | |
70 | { |
- | |
71 | dword Checksum; // ((Width ROL 16) OR Height) XOR Data[0] ; ignored so far |
- | |
72 | dword Width; |
- | |
73 | dword Height; |
- | |
74 | dword Next; |
- | |
75 | dword Previous; |
- | |
76 | dword Type; // one of Image.bppN |
- | |
77 | dword Data; |
- | |
78 | dword Palette; // used iff Type eq Image.bpp1, Image.bpp2, Image.bpp4 or Image.bpp8i |
- | |
79 | dword Extended; |
- | |
80 | dword Flags; // bitfield |
- | |
81 | dword Delay; // used iff Image.IsAnimated is set in Flags |
- | |
82 | }; |
- | |
83 | 68 | ||
84 | // values for Image.Type |
69 | // values for Image.Type |
85 | // must be consecutive to allow fast switch on Image.Type in support functions |
70 | // must be consecutive to allow fast switch on Image.Type in support functions |
86 | #define Image_bpp8i 1 // indexed |
71 | #define IMAGE_BPP8i 1 // indexed |
87 | #define Image_bpp24 2 |
72 | #define IMAGE_BPP24 2 |
88 | #define Image_bpp32 3 |
73 | #define IMAGE_BPP32 3 |
89 | #define Image_bpp15 4 |
74 | #define IMAGE_BPP15 4 |
90 | #define Image_bpp16 5 |
75 | #define IMAGE_BPP16 5 |
91 | #define Image_bpp1 6 |
76 | #define IMAGE_BPP1 6 |
92 | #define Image_bpp8g 7 // grayscale |
77 | #define IMAGE_BPP8g 7 // grayscale |
93 | #define Image_bpp2i 8 |
78 | #define IMAGE_BPP2i 8 |
94 | #define Image_bpp4i 9 |
79 | #define IMAGE_BPP4i 9 |
95 | #define Image_bpp8a 10 // grayscale with alpha channel; application layer only!!! |
80 | #define IMAGE_BPP8a 10 // grayscale with alpha channel; application layer only!!! |
96 | // kernel doesn't handle this image type, |
81 | // kernel doesn't handle this image type, |
Line -... | Line 82... | ||
- | 82 | // libimg can only create and destroy such images |
|
- | 83 | ||
- | 84 | struct libimg_image |
|
- | 85 | { |
|
- | 86 | dword checksum; // ((Width ROL 16) OR Height) XOR Data[0] ; ignored so far |
|
- | 87 | dword w; |
|
- | 88 | dword h; |
|
- | 89 | dword next; |
|
- | 90 | dword previous; |
|
- | 91 | dword type; // one of Image.bppN |
|
- | 92 | dword imgsrc; |
|
- | 93 | dword palette; // used iff Type eq Image.bpp1, Image.bpp2, Image.bpp4 or Image.bpp8i |
|
- | 94 | dword extended; |
|
- | 95 | dword flags; // bitfield |
|
- | 96 | dword delay; // used iff Image.IsAnimated is set in Flags |
|
- | 97 | dword image; |
|
- | 98 | void load(); |
|
- | 99 | void convert_into(); |
|
- | 100 | void replace_color(); |
|
- | 101 | void set_vars(); |
|
- | 102 | void draw(); |
|
- | 103 | }; |
|
- | 104 | ||
- | 105 | :void libimg_image::set_vars() |
|
- | 106 | { |
|
- | 107 | $push edi |
|
- | 108 | EDI = image; |
|
- | 109 | checksum = DSWORD[EDI]; |
|
- | 110 | w = ESDWORD[EDI+4]; |
|
- | 111 | h = ESDWORD[EDI+8]; |
|
- | 112 | next = ESDWORD[EDI+12]; |
|
- | 113 | previous = ESDWORD[EDI+16]; |
|
- | 114 | imgsrc = ESDWORD[EDI+24]; |
|
- | 115 | palette = ESDWORD[EDI+28]; |
|
- | 116 | extended = ESDWORD[EDI+32]; |
|
- | 117 | flags = ESDWORD[EDI+36]; |
|
- | 118 | delay = ESDWORD[EDI+40]; |
|
- | 119 | $pop edi |
|
- | 120 | } |
|
- | 121 | ||
- | 122 | :void libimg_image::load(dword file_path) |
|
- | 123 | { |
|
- | 124 | load_image(file_path); |
|
- | 125 | if (!EAX) { |
|
- | 126 | notify("'Error: Image not loaded'E"); |
|
- | 127 | } else { |
|
- | 128 | image = EAX; |
|
- | 129 | set_vars(); |
|
- | 130 | } |
|
- | 131 | } |
|
- | 132 | ||
- | 133 | :void libimg_image::replace_color(dword old_color, new_color) |
|
- | 134 | { |
|
- | 135 | EDX = w * h * 4 + imgsrc; |
|
- | 136 | for (ESI = imgsrc; ESI < EDX; ESI += 4) if (DSDWORD[ESI]==old_color) DSDWORD[ESI] = new_color; |
|
- | 137 | } |
|
- | 138 | ||
- | 139 | :void libimg_image::draw(dword _x, _y, _w, _h, _xoff, _yoff) |
|
- | 140 | { |
|
- | 141 | if (image) img_draw stdcall(image, _x, _y, _w, _h, _xoff, _yoff); |
|
- | 142 | } |
|
- | 143 | ||
- | 144 | :void libimg_image::convert_into(dword _to) |
|
- | 145 | { |
|
- | 146 | img_convert stdcall(image, 0, _to, 0, 0); |
|
- | 147 | if (!EAX) { |
|
- | 148 | notify("'LibImg convertation error!'E"); |
|
- | 149 | } else { |
|
- | 150 | image = EAX; |
|
- | 151 | set_vars(); |
|
Line 97... | Line 152... | ||
97 | // libimg can only create and destroy such images |
152 | } |
98 | 153 | } |
|
99 | 154 | ||
100 | :dword load_image(dword filename) |
155 | :dword load_image(dword filename) |
Line 183... | Line 238... | ||
183 | ESDWORD[size] = ECX; |
238 | ESDWORD[size] = ECX; |
Line 184... | Line 239... | ||
184 | 239 | ||
185 | return EAX; |
240 | return EAX; |
Line 186... | Line -... | ||
186 | } |
- | |
187 | - | ||
188 | :void DrawLibImage(dword image_pointer,x,y,w,h,offx,offy) { |
- | |
189 | img_draw stdcall ( |
- | |
190 | image_pointer, |
- | |
191 | x, |
- | |
192 | y, |
- | |
193 | w, |
- | |
194 | h, |
- | |
195 | offx, |
- | |
196 | offy |
- | |
197 | ); |
- | |
198 | } |
241 | } |
199 | 242 | ||
200 | //NOTICE: DO NOT FORGET TO INIT libio AND libimg!!! |
243 | //NOTICE: DO NOT FORGET TO INIT libio AND libimg!!! |
201 | #ifdef LANG_RUS |
244 | #ifdef LANG_RUS |
202 | #define TEXT_FILE_SAVED_AS "' ©« á®åà ¥ ª ª " |
245 | #define TEXT_FILE_SAVED_AS "' ©« á®åà ¥ ª ª " |
Line 208... | Line 251... | ||
208 | char save_success_message[4096+200]; |
251 | char save_success_message[4096+200]; |
209 | dword encoded_data=0; |
252 | dword encoded_data=0; |
210 | dword encoded_size=0; |
253 | dword encoded_size=0; |
211 | dword image_ptr = 0; |
254 | dword image_ptr = 0; |
Line 212... | Line 255... | ||
212 | 255 | ||
Line 213... | Line 256... | ||
213 | image_ptr = create_image(Image_bpp24, _w, _h); |
256 | image_ptr = create_image(IMAGE_BPP24, _w, _h); |
214 | 257 | ||
215 | if (image_ptr == 0) { |
258 | if (image_ptr == 0) { |
216 | notify("'Error saving file, probably not enought memory!' -E"); |
259 | notify("'Error saving file, probably not enought memory!' -E"); |
217 | } |
260 | } |
218 | else { |
261 | else { |
Line 219... | Line 262... | ||
219 | EDI = image_ptr; |
262 | EDI = image_ptr; |
Line 220... | Line 263... | ||
220 | memmov(EDI._Image.Data, _image_pointer, _w * _h * 3); |
263 | memmov(EDI.libimg_image.imgsrc, _image_pointer, _w * _h * 3); |
Line 238... | Line 281... | ||
238 | } |
281 | } |
239 | } |
282 | } |
240 | } |
283 | } |
241 | } |
284 | } |
Line 242... | Line -... | ||
242 | - | ||
243 | :dword convert_image(dword _image_pointer, _w, _h, _path) |
- | |
244 | { |
- | |
245 | img_convert stdcall(_image_pointer, 0, Image_bpp32, 0, 0); |
- | |
246 | if (EAX!=0) |
- | |
247 | mov [image_converted], eax |
- | |
Line -... | Line 285... | ||
- | 285 | ||
- | 286 | ||
- | 287 | ||
- | 288 | ///////////////////////////// |
|
- | 289 | /* |
|
- | 290 | // DRAW ICON PATTERN / TEMP |
|
- | 291 | */ |
|
- | 292 | ///////////////////////////// |
|
- | 293 | ||
- | 294 | :void DrawIcon32(dword x,y, _bg, icon_n) { |
|
- | 295 | static libimg_image i32; |
|
248 | } |
296 | static dword bg; |
- | 297 | //load_dll(libimg, #libimg_init,1); |
|
- | 298 | if (!i32.image) || (bg!=_bg) { |
|
- | 299 | bg = _bg; |
|
- | 300 | i32.load("/sys/icons32.png"); |
|
- | 301 | i32.replace_color(0x00000000, bg); |
|
- | 302 | debugln("wolo"); |
|
- | 303 | } |
|
- | 304 | if (icon_n>=0) i32.draw(x, y, 32, 32, 0, icon_n*32); |
|
- | 305 | } |
|
- | 306 | ||
249 | 307 | :void DrawIcon16(dword x,y, bg, icon_n) { |
|
- | 308 | static libimg_image i16; |
|
- | 309 | //load_dll(libimg, #libimg_init,1); |
|
- | 310 | if (!i16.image) { |
|
- | 311 | i16.load("/sys/icons16.png"); |
|
250 | #ifndef INCLUDE_LIBIMG_LOAD_SKIN_H |
312 | i16.replace_color(0xffFFFfff, bg); |
- | 313 | i16.replace_color(0xffCACBD6, MixColors(bg, 0, 220)); |
|
- | 314 | } |
|
Line 251... | Line 315... | ||
251 | #include "../lib/patterns/libimg_load_skin.h" |
315 | if (icon_n>=0) i16.draw(x, y, 16, 16, 0, icon_n*16); |
252 | #endif |
316 | } |