Rev 7928 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5598 | pavelyakov | 1 | #ifndef INCLUDE_LIBIMG_LOAD_SKIN_H |
2 | #define INCLUDE_LIBIMG_LOAD_SKIN_H |
||
3 | |||
4 | #ifndef INCLUDE_LIBIMG_H |
||
7049 | leency | 5 | #include "../lib/obj/libimg.h" |
5598 | pavelyakov | 6 | #endif |
7 | |||
5773 | leency | 8 | :struct libimg_image { |
7156 | leency | 9 | dword image, w, h, imgsrc; |
7977 | leency | 10 | void load_as24b(); |
11 | void load(); |
||
12 | void replace_color(); |
||
13 | void fill_transparent(); |
||
5773 | leency | 14 | } skin; |
5408 | leency | 15 | |
7977 | leency | 16 | :void libimg_image::load_as24b(dword file_path) |
5408 | leency | 17 | { |
7977 | leency | 18 | dword image_pointer = load_image(file_path); |
5421 | leency | 19 | if (!image_pointer) notify("'Error: Image not loaded' -E"); |
7977 | leency | 20 | |
21 | img_convert stdcall(image_pointer, 0, Image_bpp24, 0, 0); |
||
22 | if (!EAX) { |
||
23 | notify("'Error: Image can not be converted to 24b' -E"); |
||
24 | } else { |
||
25 | image = image_pointer = EAX; |
||
26 | w = DSWORD[image_pointer+4]; |
||
27 | h = DSWORD[image_pointer+8]; |
||
28 | imgsrc = ESDWORD[image_pointer+24]; |
||
29 | } |
||
5409 | leency | 30 | } |
31 | |||
7977 | leency | 32 | :void libimg_image::load(dword file_path) |
5409 | leency | 33 | { |
7977 | leency | 34 | dword image_pointer = load_image(file_path); |
35 | if (!EAX) { |
||
36 | notify("'Error: Image not loaded' -E"); |
||
37 | } else { |
||
38 | image = image_pointer = EAX; |
||
39 | w = DSWORD[image_pointer+4]; |
||
40 | h = DSWORD[image_pointer+8]; |
||
41 | imgsrc = ESDWORD[image_pointer+24]; |
||
42 | } |
||
43 | |||
5598 | pavelyakov | 44 | } |
45 | |||
7977 | leency | 46 | :void libimg_image::replace_color(dword old_color, new_color) |
7054 | leency | 47 | { |
7977 | leency | 48 | dword i, max_i; |
49 | max_i = w * h * 4 + imgsrc; |
||
50 | for (i = imgsrc; i < max_i; i += 4) if (DSDWORD[i]==old_color) DSDWORD[i] = new_color; |
||
7054 | leency | 51 | } |
52 | |||
7977 | leency | 53 | :void libimg_image::fill_transparent(new_color) |
54 | { |
||
55 | if (new_color) replace_color(0, new_color); |
||
56 | } |
||
57 | |||
7229 | leency | 58 | :libimg_image icons32draw; |
59 | :void DrawIcon32(dword x,y, bg, icon_n) { |
||
60 | //load_dll(libimg, #libimg_init,1); |
||
61 | if (!icons32draw.image) { |
||
7977 | leency | 62 | icons32draw.load("/sys/icons32.png"); |
63 | icons32draw.fill_transparent(bg); |
||
7229 | leency | 64 | } |
65 | if (icon_n>=0) img_draw stdcall(icons32draw.image, x, y, 32, 32, 0, icon_n*32); |
||
66 | } |
||
67 | |||
7906 | leency | 68 | :libimg_image icons16draw; |
69 | :void DrawIcon16(dword x,y, bg, icon_n) { |
||
70 | //load_dll(libimg, #libimg_init,1); |
||
71 | if (!icons16draw.image) { |
||
7977 | leency | 72 | icons16draw.load("/sys/icons16.png"); |
73 | icons16draw.replace_color(0xffFFFfff, bg); |
||
74 | icons16draw.replace_color(0xffCACBD6, MixColors(bg, 0, 220)); |
||
7906 | leency | 75 | } |
76 | if (icon_n>=0) img_draw stdcall(icons16draw.image, x, y, 16, 16, 0, icon_n*16); |
||
77 | } |
||
78 | |||
5598 | pavelyakov | 79 | #endif> |