2015-07-22 20:32:54 +02:00
|
|
|
#ifndef INCLUDE_LIBIMG_LOAD_SKIN_H
|
|
|
|
#define INCLUDE_LIBIMG_LOAD_SKIN_H
|
|
|
|
|
|
|
|
#ifndef INCLUDE_LIBIMG_H
|
2017-10-05 00:59:57 +02:00
|
|
|
#include "../lib/obj/libimg.h"
|
2015-07-22 20:32:54 +02:00
|
|
|
#endif
|
|
|
|
|
2015-08-27 01:45:56 +02:00
|
|
|
:struct libimg_image {
|
2018-02-10 12:47:33 +01:00
|
|
|
dword image, w, h, imgsrc;
|
2020-05-24 18:46:26 +02:00
|
|
|
void load_as24b();
|
|
|
|
void load();
|
|
|
|
void replace_color();
|
|
|
|
void fill_transparent();
|
2015-08-27 01:45:56 +02:00
|
|
|
} skin;
|
2015-02-15 11:18:26 +01:00
|
|
|
|
2020-05-24 18:46:26 +02:00
|
|
|
:void libimg_image::load_as24b(dword file_path)
|
2015-02-15 11:18:26 +01:00
|
|
|
{
|
2020-05-24 18:46:26 +02:00
|
|
|
dword image_pointer = load_image(file_path);
|
2015-02-18 20:52:40 +01:00
|
|
|
if (!image_pointer) notify("'Error: Image not loaded' -E");
|
2020-05-24 18:46:26 +02:00
|
|
|
|
|
|
|
img_convert stdcall(image_pointer, 0, Image_bpp24, 0, 0);
|
|
|
|
if (!EAX) {
|
|
|
|
notify("'Error: Image can not be converted to 24b' -E");
|
|
|
|
} else {
|
|
|
|
image = image_pointer = EAX;
|
|
|
|
w = DSWORD[image_pointer+4];
|
|
|
|
h = DSWORD[image_pointer+8];
|
|
|
|
imgsrc = ESDWORD[image_pointer+24];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
:void libimg_image::load(dword file_path)
|
|
|
|
{
|
|
|
|
dword image_pointer = load_image(file_path);
|
|
|
|
if (!EAX) {
|
|
|
|
notify("'Error: Image not loaded' -E");
|
|
|
|
} else {
|
|
|
|
image = image_pointer = EAX;
|
|
|
|
w = DSWORD[image_pointer+4];
|
|
|
|
h = DSWORD[image_pointer+8];
|
|
|
|
imgsrc = ESDWORD[image_pointer+24];
|
|
|
|
}
|
|
|
|
|
2015-02-15 11:54:50 +01:00
|
|
|
}
|
|
|
|
|
2020-05-24 18:46:26 +02:00
|
|
|
:void libimg_image::replace_color(dword old_color, new_color)
|
2015-02-15 11:54:50 +01:00
|
|
|
{
|
2020-05-24 18:46:26 +02:00
|
|
|
dword i, max_i;
|
|
|
|
max_i = w * h * 4 + imgsrc;
|
|
|
|
for (i = imgsrc; i < max_i; i += 4) if (DSDWORD[i]==old_color) DSDWORD[i] = new_color;
|
2015-07-22 20:32:54 +02:00
|
|
|
}
|
|
|
|
|
2020-05-24 18:46:26 +02:00
|
|
|
:void libimg_image::fill_transparent(new_color)
|
2017-10-05 23:38:09 +02:00
|
|
|
{
|
2020-05-24 18:46:26 +02:00
|
|
|
if (new_color) replace_color(0, new_color);
|
2018-04-16 11:30:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
:libimg_image icons32draw;
|
|
|
|
:void DrawIcon32(dword x,y, bg, icon_n) {
|
|
|
|
//load_dll(libimg, #libimg_init,1);
|
|
|
|
if (!icons32draw.image) {
|
2020-05-24 18:46:26 +02:00
|
|
|
icons32draw.load("/sys/icons32.png");
|
|
|
|
icons32draw.fill_transparent(bg);
|
2018-04-16 11:30:24 +02:00
|
|
|
}
|
|
|
|
if (icon_n>=0) img_draw stdcall(icons32draw.image, x, y, 32, 32, 0, icon_n*32);
|
2017-10-05 23:38:09 +02:00
|
|
|
}
|
|
|
|
|
2020-05-10 03:44:40 +02:00
|
|
|
:libimg_image icons16draw;
|
|
|
|
:void DrawIcon16(dword x,y, bg, icon_n) {
|
|
|
|
//load_dll(libimg, #libimg_init,1);
|
|
|
|
if (!icons16draw.image) {
|
2020-05-24 18:46:26 +02:00
|
|
|
icons16draw.load("/sys/icons16.png");
|
|
|
|
icons16draw.replace_color(0xffFFFfff, bg);
|
|
|
|
icons16draw.replace_color(0xffCACBD6, MixColors(bg, 0, 220));
|
2020-05-10 03:44:40 +02:00
|
|
|
}
|
|
|
|
if (icon_n>=0) img_draw stdcall(icons16draw.image, x, y, 16, 16, 0, icon_n*16);
|
|
|
|
}
|
|
|
|
|
2015-07-22 20:32:54 +02:00
|
|
|
#endif
|