Subversion Repositories Kolibri OS

Rev

Rev 7977 | 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();
5773 leency 13
} skin;
5408 leency 14
 
7977 leency 15
:void libimg_image::load_as24b(dword file_path)
5408 leency 16
{
7977 leency 17
	dword image_pointer = load_image(file_path);
5421 leency 18
	if (!image_pointer) notify("'Error: Image not loaded' -E");
7977 leency 19
 
20
	img_convert stdcall(image_pointer, 0, Image_bpp24, 0, 0);
21
	if (!EAX) {
22
		notify("'Error: Image can not be converted to 24b' -E");
23
	} else {
24
		image = image_pointer = EAX;
25
		w = DSWORD[image_pointer+4];
26
		h = DSWORD[image_pointer+8];
27
		imgsrc = ESDWORD[image_pointer+24];
28
	}
5409 leency 29
}
30
 
7977 leency 31
:void libimg_image::load(dword file_path)
5409 leency 32
{
7977 leency 33
	dword image_pointer = load_image(file_path);
34
	if (!EAX) {
35
		notify("'Error: Image not loaded' -E");
36
	} else {
37
		image = image_pointer = EAX;
38
		w = DSWORD[image_pointer+4];
39
		h = DSWORD[image_pointer+8];
40
		imgsrc = ESDWORD[image_pointer+24];
41
	}
42
 
5598 pavelyakov 43
}
44
 
7977 leency 45
:void libimg_image::replace_color(dword old_color, new_color)
7054 leency 46
{
7977 leency 47
	dword i, max_i;
48
	max_i =  w * h * 4 + imgsrc;
49
	for (i = imgsrc; i < max_i; i += 4)	if (DSDWORD[i]==old_color) DSDWORD[i] = new_color;
7054 leency 50
}
51
 
7229 leency 52
:libimg_image icons32draw;
53
:void DrawIcon32(dword x,y, bg, icon_n) {
54
	//load_dll(libimg, #libimg_init,1);
55
	if (!icons32draw.image) {
7977 leency 56
		icons32draw.load("/sys/icons32.png");
7978 leency 57
		icons32draw.replace_color(0x00000000, bg);
7229 leency 58
	}
59
	if (icon_n>=0) img_draw stdcall(icons32draw.image, x, y, 32, 32, 0, icon_n*32);
60
}
61
 
7906 leency 62
:libimg_image icons16draw;
63
:void DrawIcon16(dword x,y, bg, icon_n) {
64
	//load_dll(libimg, #libimg_init,1);
65
	if (!icons16draw.image) {
7977 leency 66
		icons16draw.load("/sys/icons16.png");
67
		icons16draw.replace_color(0xffFFFfff, bg);
68
		icons16draw.replace_color(0xffCACBD6, MixColors(bg, 0, 220));
7906 leency 69
	}
70
	if (icon_n>=0) img_draw stdcall(icons16draw.image, x, y, 16, 16, 0, icon_n*16);
71
}
72
 
5598 pavelyakov 73
#endif