From adf7624efefa524bdcfee0ac82facac96558fc45 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Sun, 13 Dec 2020 11:48:29 +0000 Subject: [PATCH] avoid using libio in img.load() git-svn-id: svn://kolibrios.org@8389 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/barscfg/barscfg.c | 1 - programs/cmm/iconedit/iconedit.c | 2 - programs/cmm/installer/install.c | 2 - programs/cmm/lib/obj/libimg.h | 79 +---------------------------- programs/cmm/liza/liza.c | 2 - programs/cmm/misc/easyshot.c | 2 - programs/cmm/misc/software_widget.c | 2 - programs/cmm/mousecfg/mousecfg.c | 1 - programs/cmm/pixie2/pixie.c | 2 - programs/cmm/quark/quark.c | 2 - programs/cmm/taskbar2/taskbar2.c | 2 - programs/cmm/the_bus/the_bus.c | 2 - 12 files changed, 2 insertions(+), 97 deletions(-) diff --git a/programs/cmm/barscfg/barscfg.c b/programs/cmm/barscfg/barscfg.c index a199f021ec..1275778c4f 100644 --- a/programs/cmm/barscfg/barscfg.c +++ b/programs/cmm/barscfg/barscfg.c @@ -10,7 +10,6 @@ #include "..\lib\dll.h" #include "..\lib\gui.h" -#include "..\lib\obj\libio.h" #include "..\lib\obj\libini.h" #include "..\lib\obj\box_lib.h" diff --git a/programs/cmm/iconedit/iconedit.c b/programs/cmm/iconedit/iconedit.c index 3ecdf502a4..9772267ff6 100644 --- a/programs/cmm/iconedit/iconedit.c +++ b/programs/cmm/iconedit/iconedit.c @@ -13,7 +13,6 @@ #include "../lib/list_box.h" #include "../lib/events.h" -#include "../lib/obj/libio.h" #include "../lib/obj/libimg.h" #include "../lib/obj/box_lib.h" @@ -169,7 +168,6 @@ void main() word btn; libimg_image open_image; - load_dll(libio, #libio_init, 1); load_dll(libimg, #libimg_init, 1); load_dll(boxlib, #box_lib_init,0); diff --git a/programs/cmm/installer/install.c b/programs/cmm/installer/install.c index 87733321a3..aee557e63b 100644 --- a/programs/cmm/installer/install.c +++ b/programs/cmm/installer/install.c @@ -5,7 +5,6 @@ #include "../lib/copyf.h" #include "../lib/obj/libini.h" -#include "../lib/obj/libio.h" #include "../lib/obj/libimg.h" #include "../lib/patterns/restart_process.h" @@ -45,7 +44,6 @@ void main() { word btn; load_dll(libini, #lib_init,1); - load_dll(libio, #libio_init,1); load_dll(libimg, #libimg_init,1); loop() switch(WaitEventTimeout(300) & 0xFF) { diff --git a/programs/cmm/lib/obj/libimg.h b/programs/cmm/lib/obj/libimg.h index 71831f81e9..dd4e086de7 100644 --- a/programs/cmm/lib/obj/libimg.h +++ b/programs/cmm/lib/obj/libimg.h @@ -119,7 +119,8 @@ struct libimg_image :void libimg_image::load(dword file_path) { - load_image(file_path); + if (image) img_destroy stdcall(image); + img_from_file stdcall(file_path); if (!EAX) { notify("'Error: Image not loaded'E"); } else { @@ -150,81 +151,6 @@ struct libimg_image } } -:dword load_image(dword filename) -{ - //align 4 - dword img_data=0; - dword img_data_len=0; - dword fh=0; - dword image=0; - - byte tmp_buf[40]; - $and img_data, 0 - //$mov eax, filename - //$push eax - //invoke file.open, eax, O_READ - file_open stdcall (filename, O_READ); - $or eax, eax - $jnz loc05 - $stc - return 0; - @loc05: - $mov fh, eax - //invoke file.size - file_size stdcall (filename); - $mov img_data_len, ebx - //stdcall mem.Alloc, ebx - mem_Alloc(EBX); - - $test eax, eax - $jz error_close - $mov img_data, eax - //invoke file.read, [fh], eax, [img_data_len] - file_read stdcall (fh, EAX, img_data_len); - $cmp eax, -1 - $jz error_close - $cmp eax, img_data_len - $jnz error_close - //invoke file.close, [fh] - file_close stdcall (fh); - $inc eax - $jz error_ -//; img.decode checks for img.is_img -//; //invoke img.is_img, [img_data], [img_data_len] -//; $or eax, eax -//; $jz exit - //invoke img.decode, [img_data], [img_data_len], 0 - EAX=img_data; - img_decode stdcall (EAX, img_data_len,0); - $or eax, eax - $jz error_ - $cmp image, 0 - $pushf - $mov image, eax - //call init_frame - $popf - //call update_image_sizes - mem_Free(img_data);//free_img_data(img_data); - $clc - return image; - -@error_free: - //invoke img.destroy, [image] - img_destroy stdcall (image); - $jmp error_ - -@error_pop: - $pop eax - $jmp error_ -@error_close: - //invoke file.close, [fh] - file_close stdcall (fh); -@error_: - mem_Free(img_data); - $stc - return 0; -} - :dword create_image(dword type, dword width, dword height) { img_create stdcall(width, height, type); return EAX; @@ -238,7 +164,6 @@ struct libimg_image return EAX; } -//NOTICE: DO NOT FORGET TO INIT libio AND libimg!!! #ifdef LANG_RUS #define TEXT_FILE_SAVED_AS "'Файл сохранен как " #else diff --git a/programs/cmm/liza/liza.c b/programs/cmm/liza/liza.c index dbebbd8f7b..cedd7c9129 100644 --- a/programs/cmm/liza/liza.c +++ b/programs/cmm/liza/liza.c @@ -17,7 +17,6 @@ #include "../lib/obj/box_lib.h" #include "../lib/obj/network.h" #include "../lib/obj/http.h" -#include "../lib/obj/libio.h" #include "../lib/obj/libimg.h" #include "../lib/obj/netcode.h" #include "../lib/obj/iconv.h" @@ -113,7 +112,6 @@ void main() { load_dll(boxlib, #box_lib_init,0); load_dll(network_lib, #network_lib_init,0); load_dll(netcode_lib, #base64_encode,0); - load_dll(libio, #libio_init,1); load_dll(libimg, #libimg_init,1); load_dll(iconv_lib, #iconv_open,0); OpenMailDat(); diff --git a/programs/cmm/misc/easyshot.c b/programs/cmm/misc/easyshot.c index 7bc8b24d8a..9dfff0a177 100644 --- a/programs/cmm/misc/easyshot.c +++ b/programs/cmm/misc/easyshot.c @@ -4,7 +4,6 @@ #include "../lib/mem.h" #include "../lib/gui.h" -#include "../lib/obj/libio.h" #include "../lib/obj/libimg.h" #include "../lib/obj/box_lib.h" #include "../lib/obj/proc_lib.h" @@ -75,7 +74,6 @@ opendialog open_folder_dialog = void init_libraries() { - load_dll(libio, #libio_init, 1); load_dll(libimg, #libimg_init, 1); load_dll(boxlib, #box_lib_init,0); load_dll(Proc_lib, #OpenDialog_init,0); diff --git a/programs/cmm/misc/software_widget.c b/programs/cmm/misc/software_widget.c index 5ae658f55f..8764ac7b37 100644 --- a/programs/cmm/misc/software_widget.c +++ b/programs/cmm/misc/software_widget.c @@ -7,7 +7,6 @@ SOFTWARE CENTER v2.86 #include "..\lib\mem.h" #include "..\lib\gui.h" -#include "..\lib\obj\libio.h" #include "..\lib\obj\libimg.h" #include "..\lib\obj\libini.h" #include "..\lib\kfont.h" @@ -59,7 +58,6 @@ void main() { dword id; kfont.init(DEFAULT_FONT); - load_dll(libio, #libio_init,1); load_dll(libimg, #libimg_init,1); load_dll(libini, #lib_init,1); diff --git a/programs/cmm/mousecfg/mousecfg.c b/programs/cmm/mousecfg/mousecfg.c index 2c9479df93..0306a5b0ed 100644 --- a/programs/cmm/mousecfg/mousecfg.c +++ b/programs/cmm/mousecfg/mousecfg.c @@ -10,7 +10,6 @@ #include "..\lib\mem.h" #include "..\lib\fs.h" #include "..\lib\gui.h" -#include "..\lib\obj\libio.h" #include "..\lib\obj\libini.h" #include "..\lib\patterns\restart_process.h" diff --git a/programs/cmm/pixie2/pixie.c b/programs/cmm/pixie2/pixie.c index 8dfc8b36da..a47bac10f2 100644 --- a/programs/cmm/pixie2/pixie.c +++ b/programs/cmm/pixie2/pixie.c @@ -12,7 +12,6 @@ #include "../lib/random.h" #include "../lib/kfont.h" -#include "../lib/obj/libio.h" #include "../lib/obj/libimg.h" #include "../lib/obj/libini.h" #include "../lib/obj/proc_lib.h" @@ -112,7 +111,6 @@ libimg_image skin; void LoadLibraries() { load_dll(boxlib, #box_lib_init,0); - load_dll(libio, #libio_init,1); load_dll(libimg, #libimg_init,1); load_dll(libini, #lib_init,1); load_dll(Proc_lib, #OpenDialog_init,0); diff --git a/programs/cmm/quark/quark.c b/programs/cmm/quark/quark.c index 4187ef77fa..20936db7d8 100644 --- a/programs/cmm/quark/quark.c +++ b/programs/cmm/quark/quark.c @@ -28,7 +28,6 @@ #include "../lib/obj/box_lib.h" #include "../lib/obj/libini.h" -#include "../lib/obj/libio.h" #include "../lib/obj/libimg.h" #include "../lib/obj/iconv.h" #include "../lib/obj/proc_lib.h" @@ -105,7 +104,6 @@ EVENTS key; void InitDlls() { load_dll(boxlib, #box_lib_init, 0); - load_dll(libio, #libio_init, 1); load_dll(libimg, #libimg_init, 1); load_dll(libini, #lib_init, 1); load_dll(iconv_lib, #iconv_open, 0); diff --git a/programs/cmm/taskbar2/taskbar2.c b/programs/cmm/taskbar2/taskbar2.c index 54dc46875f..0c7aa51d49 100644 --- a/programs/cmm/taskbar2/taskbar2.c +++ b/programs/cmm/taskbar2/taskbar2.c @@ -14,7 +14,6 @@ #include "../lib/mem.h" -#include "../lib/obj/libio.h" #include "../lib/obj/libimg.h" #include "../lib/obj/libini.h" @@ -62,7 +61,6 @@ dword COLOR_TEXT = 0xFFFfff; void main() { int btn; - load_dll(libio, #libio_init,1); load_dll(libimg, #libimg_init,1); load_dll(libini, #lib_init,1); diff --git a/programs/cmm/the_bus/the_bus.c b/programs/cmm/the_bus/the_bus.c index 26400fd5b8..1a49edf343 100644 --- a/programs/cmm/the_bus/the_bus.c +++ b/programs/cmm/the_bus/the_bus.c @@ -15,7 +15,6 @@ Copyright (C) 2008 O.Bogomaz #include "..\lib\kolibri.h" #include "..\lib\random.h" -#include "..\lib\obj\libio.h" #include "..\lib\obj\libimg.h" libimg_image menu; @@ -124,7 +123,6 @@ void main() randomize(); StartNewGame(); - load_dll(libio, #libio_init,1); load_dll(libimg, #libimg_init,1); menu.load(abspath("menu.png")); road.load(abspath("road.png"));