software_widget: use parrern for libimg_image

git-svn-id: svn://kolibrios.org@5409 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2015-02-15 10:54:50 +00:00
parent 81ef95c4b3
commit 7f549cc040
2 changed files with 19 additions and 28 deletions

View File

@ -2,12 +2,20 @@ struct libimg_image {
dword image, w, h; dword image, w, h;
}; };
int Libimg_LoadImage(dword struct_pointer, file_path) :void Libimg_LoadImage(dword struct_pointer, file_path)
{ {
int image_pointer; dword image_pointer;
image_pointer = load_image(file_path); image_pointer = load_image(file_path);
if (!image_pointer) notify("Error: Skin not loaded"); if (!image_pointer) notify("Error: Image not loaded");
ESDWORD[struct_pointer] = image_pointer; ESDWORD[struct_pointer] = image_pointer;
ESDWORD[struct_pointer+4] = DSWORD[image_pointer+4]; ESDWORD[struct_pointer+4] = DSWORD[image_pointer+4];
ESDWORD[struct_pointer+8] = DSWORD[image_pointer+8]; ESDWORD[struct_pointer+8] = DSWORD[image_pointer+8];
} }
:void Libimg_FillTransparent(dword struct_pointer, w, h, new_transparent_color)
{
dword i, max_i, image_data;
image_data = ESDWORD[struct_pointer + 24];
max_i = w * h * 4 + image_data;
for (i = image_data; i < max_i; i += 4) if (DSDWORD[i]==0) DSDWORD[i] = new_transparent_color;
}

View File

@ -1,5 +1,5 @@
/* /*
SOFTWARE CENTER v2.2 SOFTWARE CENTER v2.21
*/ */
#define MEMSIZE 0x3E80 #define MEMSIZE 0x3E80
@ -9,10 +9,12 @@ SOFTWARE CENTER v2.2
#include "..\lib\file_system.h" #include "..\lib\file_system.h"
#include "..\lib\dll.h" #include "..\lib\dll.h"
#include "..\lib\figures.h" #include "..\lib\figures.h"
#include "..\lib\lib.obj\libio_lib.h" #include "..\lib\lib.obj\libio_lib.h"
#include "..\lib\lib.obj\libimg_lib.h" #include "..\lib\lib.obj\libimg_lib.h"
#include "..\lib\lib.obj\libini.h" #include "..\lib\lib.obj\libini.h"
#include "..\lib\patterns\libimg_load_skin.h"
system_colors sc; system_colors sc;
proc_info Form; proc_info Form;
@ -38,28 +40,7 @@ char window_title[128],
#define LIST_BACKGROUND_COLOR 0xF3F3F3 #define LIST_BACKGROUND_COLOR 0xF3F3F3
libimg_image skin;
struct struct_skin {
dword image, w, h;
int load();
} skin;
int struct_skin::load()
{
int i, max_i;
dword image_data;
skin.image = load_image("/sys/iconstrp.png");
if (!skin.image) notify("'iconstrp.png not found' -E");
skin.w = DSWORD[skin.image + 4];
skin.h = DSWORD[skin.image + 8];
image_data = DSDWORD[skin.image + 24];
sc.get();
max_i = w * h * 4 + image_data;
for (i = image_data; i < max_i; i += 4) if (DSDWORD[i]==0) DSDWORD[i] = LIST_BACKGROUND_COLOR;
}
void load_config() void load_config()
{ {
@ -79,12 +60,14 @@ void load_config()
void main() void main()
{ {
int id, key; dword id, key;
mem_Init(); mem_Init();
if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio"); if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg"); if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
if (load_dll2(libini, #lib_init,1)!=0) notify("Error: library doesn't exists - libini"); if (load_dll2(libini, #lib_init,1)!=0) notify("Error: library doesn't exists - libini");
skin.load();
Libimg_LoadImage(#skin, "/sys/iconstrp.png");
Libimg_FillTransparent(skin.image, skin.w, skin.h, LIST_BACKGROUND_COLOR);
if (param) if (param)
{ {