From 7f549cc040f7d624b128fcd270891f3e042eb6a2 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Sun, 15 Feb 2015 10:54:50 +0000 Subject: [PATCH] software_widget: use parrern for libimg_image git-svn-id: svn://kolibrios.org@5409 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/lib/patterns/libimg_load_skin.h | 14 ++++++-- .../cmm/software_widget/software_widget.c | 33 +++++-------------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/programs/cmm/lib/patterns/libimg_load_skin.h b/programs/cmm/lib/patterns/libimg_load_skin.h index fa66af1e4c..eeda3d9613 100644 --- a/programs/cmm/lib/patterns/libimg_load_skin.h +++ b/programs/cmm/lib/patterns/libimg_load_skin.h @@ -2,12 +2,20 @@ struct libimg_image { 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); - if (!image_pointer) notify("Error: Skin not loaded"); + if (!image_pointer) notify("Error: Image not loaded"); ESDWORD[struct_pointer] = image_pointer; ESDWORD[struct_pointer+4] = DSWORD[image_pointer+4]; 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; } \ No newline at end of file diff --git a/programs/cmm/software_widget/software_widget.c b/programs/cmm/software_widget/software_widget.c index bc12f43360..d61ac4829f 100644 --- a/programs/cmm/software_widget/software_widget.c +++ b/programs/cmm/software_widget/software_widget.c @@ -1,5 +1,5 @@ /* -SOFTWARE CENTER v2.2 +SOFTWARE CENTER v2.21 */ #define MEMSIZE 0x3E80 @@ -9,10 +9,12 @@ SOFTWARE CENTER v2.2 #include "..\lib\file_system.h" #include "..\lib\dll.h" #include "..\lib\figures.h" + #include "..\lib\lib.obj\libio_lib.h" #include "..\lib\lib.obj\libimg_lib.h" #include "..\lib\lib.obj\libini.h" +#include "..\lib\patterns\libimg_load_skin.h" system_colors sc; proc_info Form; @@ -38,28 +40,7 @@ char window_title[128], #define LIST_BACKGROUND_COLOR 0xF3F3F3 - - - -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; -} +libimg_image skin; void load_config() { @@ -79,12 +60,14 @@ void load_config() void main() { - int id, key; + dword id, key; mem_Init(); 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(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) {