Rev 7928 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7928 | Rev 7977 | ||
---|---|---|---|
Line 5... | Line 5... | ||
5 | #include "../lib/obj/libimg.h" |
5 | #include "../lib/obj/libimg.h" |
6 | #endif |
6 | #endif |
Line 7... | Line 7... | ||
7 | 7 | ||
8 | :struct libimg_image { |
8 | :struct libimg_image { |
- | 9 | dword image, w, h, imgsrc; |
|
- | 10 | void load_as24b(); |
|
- | 11 | void load(); |
|
- | 12 | void replace_color(); |
|
9 | dword image, w, h, imgsrc; |
13 | void fill_transparent(); |
Line 10... | Line 14... | ||
10 | } skin; |
14 | } skin; |
11 | 15 | ||
12 | :void Libimg_LoadImage(dword struct_pointer, file_path) |
- | |
13 | { |
16 | :void libimg_image::load_as24b(dword file_path) |
14 | dword image_pointer; |
17 | { |
- | 18 | dword image_pointer = load_image(file_path); |
|
- | 19 | if (!image_pointer) notify("'Error: Image not loaded' -E"); |
|
- | 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; |
|
15 | image_pointer = load_image(file_path); |
26 | w = DSWORD[image_pointer+4]; |
- | 27 | h = DSWORD[image_pointer+8]; |
|
- | 28 | imgsrc = ESDWORD[image_pointer+24]; |
|
- | 29 | } |
|
- | 30 | } |
|
- | 31 | ||
- | 32 | :void libimg_image::load(dword file_path) |
|
- | 33 | { |
|
- | 34 | dword image_pointer = load_image(file_path); |
|
- | 35 | if (!EAX) { |
|
- | 36 | notify("'Error: Image not loaded' -E"); |
|
16 | if (!image_pointer) notify("'Error: Image not loaded' -E"); |
37 | } else { |
17 | ESDWORD[struct_pointer] = image_pointer; |
38 | image = image_pointer = EAX; |
18 | ESDWORD[struct_pointer+4] = DSWORD[image_pointer+4]; |
39 | w = DSWORD[image_pointer+4]; |
- | 40 | h = DSWORD[image_pointer+8]; |
|
- | 41 | imgsrc = ESDWORD[image_pointer+24]; |
|
19 | ESDWORD[struct_pointer+8] = DSWORD[image_pointer+8]; |
42 | } |
Line 20... | Line 43... | ||
20 | ESDWORD[struct_pointer+12] = ESDWORD[image_pointer+24]; |
43 | |
21 | } |
44 | } |
22 | 45 | ||
23 | :void Libimg_ReplaceColor(dword struct_pointer, w, h, old_color, new_color) |
- | |
24 | { |
46 | :void libimg_image::replace_color(dword old_color, new_color) |
25 | dword i, max_i, image_data; |
47 | { |
26 | image_data = ESDWORD[struct_pointer + 24]; |
48 | dword i, max_i; |
Line 27... | Line 49... | ||
27 | max_i = w * h * 4 + image_data; |
49 | max_i = w * h * 4 + imgsrc; |
28 | for (i = image_data; i < max_i; i += 4) if (DSDWORD[i]==old_color) DSDWORD[i] = new_color; |
50 | for (i = imgsrc; i < max_i; i += 4) if (DSDWORD[i]==old_color) DSDWORD[i] = new_color; |
29 | } |
51 | } |
30 | 52 | ||
Line 31... | Line 53... | ||
31 | :void Libimg_FillTransparent(dword struct_pointer, w, h, new_color) |
53 | :void libimg_image::fill_transparent(new_color) |
32 | { |
54 | { |
33 | if (new_color!=0) Libimg_ReplaceColor(struct_pointer, w, h, 0, new_color); |
55 | if (new_color) replace_color(0, new_color); |
34 | } |
56 | } |
35 | 57 | ||
36 | :libimg_image icons32draw; |
58 | :libimg_image icons32draw; |
37 | :void DrawIcon32(dword x,y, bg, icon_n) { |
59 | :void DrawIcon32(dword x,y, bg, icon_n) { |
38 | //load_dll(libimg, #libimg_init,1); |
60 | //load_dll(libimg, #libimg_init,1); |
39 | if (!icons32draw.image) { |
61 | if (!icons32draw.image) { |
Line 40... | Line 62... | ||
40 | Libimg_LoadImage(#icons32draw, "/sys/icons32.png"); |
62 | icons32draw.load("/sys/icons32.png"); |
41 | Libimg_FillTransparent(icons32draw.image, icons32draw.w, icons32draw.h, bg); |
63 | icons32draw.fill_transparent(bg); |
42 | } |
64 | } |
43 | if (icon_n>=0) img_draw stdcall(icons32draw.image, x, y, 32, 32, 0, icon_n*32); |
65 | if (icon_n>=0) img_draw stdcall(icons32draw.image, x, y, 32, 32, 0, icon_n*32); |
44 | } |
66 | } |
45 | 67 | ||
46 | :libimg_image icons16draw; |
68 | :libimg_image icons16draw; |
47 | :void DrawIcon16(dword x,y, bg, icon_n) { |
69 | :void DrawIcon16(dword x,y, bg, icon_n) { |
48 | //load_dll(libimg, #libimg_init,1); |
70 | //load_dll(libimg, #libimg_init,1); |
49 | if (!icons16draw.image) { |
71 | if (!icons16draw.image) { |
Line 50... | Line 72... | ||
50 | Libimg_LoadImage(#icons16draw, "/sys/icons16.png"); |
72 | icons16draw.load("/sys/icons16.png"); |
51 | Libimg_ReplaceColor(icons16draw.image, icons16draw.w, icons16draw.h, 0xffFFFfff, bg); |
73 | icons16draw.replace_color(0xffFFFfff, bg); |