Subversion Repositories Kolibri OS

Rev

Rev 7229 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7229 Rev 7906
1
#ifndef INCLUDE_LIBIMG_LOAD_SKIN_H
1
#ifndef INCLUDE_LIBIMG_LOAD_SKIN_H
2
#define INCLUDE_LIBIMG_LOAD_SKIN_H
2
#define INCLUDE_LIBIMG_LOAD_SKIN_H
3
 
3
 
4
#ifndef INCLUDE_LIBIMG_H
4
#ifndef INCLUDE_LIBIMG_H
5
#include "../lib/obj/libimg.h"
5
#include "../lib/obj/libimg.h"
6
#endif
6
#endif
7
 
7
 
8
:struct libimg_image {
8
:struct libimg_image {
9
	dword image, w, h, imgsrc;
9
	dword image, w, h, imgsrc;
10
} skin;
10
} skin;
11
 
11
 
12
:void Libimg_LoadImage(dword struct_pointer, file_path)
12
:void Libimg_LoadImage(dword struct_pointer, file_path)
13
{
13
{
14
	dword image_pointer;
14
	dword image_pointer;
15
	image_pointer = load_image(file_path);
15
	image_pointer = load_image(file_path);
16
	if (!image_pointer) notify("'Error: Image not loaded' -E");
16
	if (!image_pointer) notify("'Error: Image not loaded' -E");
17
	ESDWORD[struct_pointer] = image_pointer;
17
	ESDWORD[struct_pointer] = image_pointer;
18
	ESDWORD[struct_pointer+4] = DSWORD[image_pointer+4];
18
	ESDWORD[struct_pointer+4] = DSWORD[image_pointer+4];
19
	ESDWORD[struct_pointer+8] = DSWORD[image_pointer+8];
19
	ESDWORD[struct_pointer+8] = DSWORD[image_pointer+8];
20
	ESDWORD[struct_pointer+12] = ESDWORD[image_pointer+24];
20
	ESDWORD[struct_pointer+12] = ESDWORD[image_pointer+24];
21
}
21
}
22
 
22
 
23
:void Libimg_ReplaceColor(dword struct_pointer, w, h, old_color, new_color)
23
:void Libimg_ReplaceColor(dword struct_pointer, w, h, old_color, new_color)
24
{
24
{
25
	dword i, max_i, image_data;
25
	dword i, max_i, image_data;
26
	image_data = ESDWORD[struct_pointer + 24];
26
	image_data = ESDWORD[struct_pointer + 24];
27
	max_i =  w * h * 4 + image_data;
27
	max_i =  w * h * 4 + image_data;
28
	for (i = image_data; i < max_i; i += 4)	if (DSDWORD[i]==old_color) DSDWORD[i] = new_color;
28
	for (i = image_data; i < max_i; i += 4)	if (DSDWORD[i]==old_color) DSDWORD[i] = new_color;
29
}
29
}
30
 
30
 
31
:void Libimg_FillTransparent(dword struct_pointer, w, h, new_color)
31
:void Libimg_FillTransparent(dword struct_pointer, w, h, new_color)
32
{
32
{
33
	Libimg_ReplaceColor(struct_pointer, w, h, 0, new_color);
33
	Libimg_ReplaceColor(struct_pointer, w, h, 0, new_color);
34
}
34
}
35
 
35
 
36
:libimg_image icons32draw;
36
:libimg_image icons32draw;
37
:void DrawIcon32(dword x,y, bg, icon_n) {
37
:void DrawIcon32(dword x,y, bg, icon_n) {
38
	//load_dll(libimg, #libimg_init,1);
38
	//load_dll(libimg, #libimg_init,1);
39
	if (!icons32draw.image) {
39
	if (!icons32draw.image) {
40
		Libimg_LoadImage(#icons32draw, "/sys/icons32.png");
40
		Libimg_LoadImage(#icons32draw, "/sys/icons32.png");
41
		Libimg_FillTransparent(icons32draw.image, icons32draw.w, icons32draw.h, bg);
41
		Libimg_FillTransparent(icons32draw.image, icons32draw.w, icons32draw.h, bg);
42
	}
42
	}
43
	if (icon_n>=0) img_draw stdcall(icons32draw.image, x, y, 32, 32, 0, icon_n*32);
43
	if (icon_n>=0) img_draw stdcall(icons32draw.image, x, y, 32, 32, 0, icon_n*32);
44
}
44
}
-
 
45
 
-
 
46
:libimg_image icons16draw;
-
 
47
:void DrawIcon16(dword x,y, bg, icon_n) {
-
 
48
	//load_dll(libimg, #libimg_init,1);
-
 
49
	if (!icons16draw.image) {
-
 
50
		Libimg_LoadImage(#icons16draw, "/sys/icons16.png");
-
 
51
		Libimg_ReplaceColor(icons16draw.image, icons16draw.w, icons16draw.h, 0xffFFFfff, bg);
-
 
52
		Libimg_ReplaceColor(icons16draw.image, icons16draw.w, icons16draw.h, 0xffCACBD6, MixColors(bg, 0, 220));
-
 
53
	}
-
 
54
	if (icon_n>=0) img_draw stdcall(icons16draw.image, x, y, 16, 16, 0, icon_n*16);
-
 
55
}
45
 
56
 
46
#endif
57
#endif