avoid using libio in img.load()

git-svn-id: svn://kolibrios.org@8389 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-12-13 11:48:29 +00:00
parent 1469a8e53d
commit adf7624efe
12 changed files with 2 additions and 97 deletions

View File

@ -10,7 +10,6 @@
#include "..\lib\dll.h" #include "..\lib\dll.h"
#include "..\lib\gui.h" #include "..\lib\gui.h"
#include "..\lib\obj\libio.h"
#include "..\lib\obj\libini.h" #include "..\lib\obj\libini.h"
#include "..\lib\obj\box_lib.h" #include "..\lib\obj\box_lib.h"

View File

@ -13,7 +13,6 @@
#include "../lib/list_box.h" #include "../lib/list_box.h"
#include "../lib/events.h" #include "../lib/events.h"
#include "../lib/obj/libio.h"
#include "../lib/obj/libimg.h" #include "../lib/obj/libimg.h"
#include "../lib/obj/box_lib.h" #include "../lib/obj/box_lib.h"
@ -169,7 +168,6 @@ void main()
word btn; word btn;
libimg_image open_image; libimg_image open_image;
load_dll(libio, #libio_init, 1);
load_dll(libimg, #libimg_init, 1); load_dll(libimg, #libimg_init, 1);
load_dll(boxlib, #box_lib_init,0); load_dll(boxlib, #box_lib_init,0);

View File

@ -5,7 +5,6 @@
#include "../lib/copyf.h" #include "../lib/copyf.h"
#include "../lib/obj/libini.h" #include "../lib/obj/libini.h"
#include "../lib/obj/libio.h"
#include "../lib/obj/libimg.h" #include "../lib/obj/libimg.h"
#include "../lib/patterns/restart_process.h" #include "../lib/patterns/restart_process.h"
@ -45,7 +44,6 @@ void main()
{ {
word btn; word btn;
load_dll(libini, #lib_init,1); load_dll(libini, #lib_init,1);
load_dll(libio, #libio_init,1);
load_dll(libimg, #libimg_init,1); load_dll(libimg, #libimg_init,1);
loop() switch(WaitEventTimeout(300) & 0xFF) loop() switch(WaitEventTimeout(300) & 0xFF)
{ {

View File

@ -119,7 +119,8 @@ struct libimg_image
:void libimg_image::load(dword file_path) :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) { if (!EAX) {
notify("'Error: Image not loaded'E"); notify("'Error: Image not loaded'E");
} else { } 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) { :dword create_image(dword type, dword width, dword height) {
img_create stdcall(width, height, type); img_create stdcall(width, height, type);
return EAX; return EAX;
@ -238,7 +164,6 @@ struct libimg_image
return EAX; return EAX;
} }
//NOTICE: DO NOT FORGET TO INIT libio AND libimg!!!
#ifdef LANG_RUS #ifdef LANG_RUS
#define TEXT_FILE_SAVED_AS "'” ©« á®åà ­¥­ ª ª " #define TEXT_FILE_SAVED_AS "'” ©« á®åà ­¥­ ª ª "
#else #else

View File

@ -17,7 +17,6 @@
#include "../lib/obj/box_lib.h" #include "../lib/obj/box_lib.h"
#include "../lib/obj/network.h" #include "../lib/obj/network.h"
#include "../lib/obj/http.h" #include "../lib/obj/http.h"
#include "../lib/obj/libio.h"
#include "../lib/obj/libimg.h" #include "../lib/obj/libimg.h"
#include "../lib/obj/netcode.h" #include "../lib/obj/netcode.h"
#include "../lib/obj/iconv.h" #include "../lib/obj/iconv.h"
@ -113,7 +112,6 @@ void main() {
load_dll(boxlib, #box_lib_init,0); load_dll(boxlib, #box_lib_init,0);
load_dll(network_lib, #network_lib_init,0); load_dll(network_lib, #network_lib_init,0);
load_dll(netcode_lib, #base64_encode,0); load_dll(netcode_lib, #base64_encode,0);
load_dll(libio, #libio_init,1);
load_dll(libimg, #libimg_init,1); load_dll(libimg, #libimg_init,1);
load_dll(iconv_lib, #iconv_open,0); load_dll(iconv_lib, #iconv_open,0);
OpenMailDat(); OpenMailDat();

View File

@ -4,7 +4,6 @@
#include "../lib/mem.h" #include "../lib/mem.h"
#include "../lib/gui.h" #include "../lib/gui.h"
#include "../lib/obj/libio.h"
#include "../lib/obj/libimg.h" #include "../lib/obj/libimg.h"
#include "../lib/obj/box_lib.h" #include "../lib/obj/box_lib.h"
#include "../lib/obj/proc_lib.h" #include "../lib/obj/proc_lib.h"
@ -75,7 +74,6 @@ opendialog open_folder_dialog =
void init_libraries() void init_libraries()
{ {
load_dll(libio, #libio_init, 1);
load_dll(libimg, #libimg_init, 1); load_dll(libimg, #libimg_init, 1);
load_dll(boxlib, #box_lib_init,0); load_dll(boxlib, #box_lib_init,0);
load_dll(Proc_lib, #OpenDialog_init,0); load_dll(Proc_lib, #OpenDialog_init,0);

View File

@ -7,7 +7,6 @@ SOFTWARE CENTER v2.86
#include "..\lib\mem.h" #include "..\lib\mem.h"
#include "..\lib\gui.h" #include "..\lib\gui.h"
#include "..\lib\obj\libio.h"
#include "..\lib\obj\libimg.h" #include "..\lib\obj\libimg.h"
#include "..\lib\obj\libini.h" #include "..\lib\obj\libini.h"
#include "..\lib\kfont.h" #include "..\lib\kfont.h"
@ -59,7 +58,6 @@ void main()
{ {
dword id; dword id;
kfont.init(DEFAULT_FONT); kfont.init(DEFAULT_FONT);
load_dll(libio, #libio_init,1);
load_dll(libimg, #libimg_init,1); load_dll(libimg, #libimg_init,1);
load_dll(libini, #lib_init,1); load_dll(libini, #lib_init,1);

View File

@ -10,7 +10,6 @@
#include "..\lib\mem.h" #include "..\lib\mem.h"
#include "..\lib\fs.h" #include "..\lib\fs.h"
#include "..\lib\gui.h" #include "..\lib\gui.h"
#include "..\lib\obj\libio.h"
#include "..\lib\obj\libini.h" #include "..\lib\obj\libini.h"
#include "..\lib\patterns\restart_process.h" #include "..\lib\patterns\restart_process.h"

View File

@ -12,7 +12,6 @@
#include "../lib/random.h" #include "../lib/random.h"
#include "../lib/kfont.h" #include "../lib/kfont.h"
#include "../lib/obj/libio.h"
#include "../lib/obj/libimg.h" #include "../lib/obj/libimg.h"
#include "../lib/obj/libini.h" #include "../lib/obj/libini.h"
#include "../lib/obj/proc_lib.h" #include "../lib/obj/proc_lib.h"
@ -112,7 +111,6 @@ libimg_image skin;
void LoadLibraries() void LoadLibraries()
{ {
load_dll(boxlib, #box_lib_init,0); load_dll(boxlib, #box_lib_init,0);
load_dll(libio, #libio_init,1);
load_dll(libimg, #libimg_init,1); load_dll(libimg, #libimg_init,1);
load_dll(libini, #lib_init,1); load_dll(libini, #lib_init,1);
load_dll(Proc_lib, #OpenDialog_init,0); load_dll(Proc_lib, #OpenDialog_init,0);

View File

@ -28,7 +28,6 @@
#include "../lib/obj/box_lib.h" #include "../lib/obj/box_lib.h"
#include "../lib/obj/libini.h" #include "../lib/obj/libini.h"
#include "../lib/obj/libio.h"
#include "../lib/obj/libimg.h" #include "../lib/obj/libimg.h"
#include "../lib/obj/iconv.h" #include "../lib/obj/iconv.h"
#include "../lib/obj/proc_lib.h" #include "../lib/obj/proc_lib.h"
@ -105,7 +104,6 @@ EVENTS key;
void InitDlls() void InitDlls()
{ {
load_dll(boxlib, #box_lib_init, 0); load_dll(boxlib, #box_lib_init, 0);
load_dll(libio, #libio_init, 1);
load_dll(libimg, #libimg_init, 1); load_dll(libimg, #libimg_init, 1);
load_dll(libini, #lib_init, 1); load_dll(libini, #lib_init, 1);
load_dll(iconv_lib, #iconv_open, 0); load_dll(iconv_lib, #iconv_open, 0);

View File

@ -14,7 +14,6 @@
#include "../lib/mem.h" #include "../lib/mem.h"
#include "../lib/obj/libio.h"
#include "../lib/obj/libimg.h" #include "../lib/obj/libimg.h"
#include "../lib/obj/libini.h" #include "../lib/obj/libini.h"
@ -62,7 +61,6 @@ dword COLOR_TEXT = 0xFFFfff;
void main() void main()
{ {
int btn; int btn;
load_dll(libio, #libio_init,1);
load_dll(libimg, #libimg_init,1); load_dll(libimg, #libimg_init,1);
load_dll(libini, #lib_init,1); load_dll(libini, #lib_init,1);

View File

@ -15,7 +15,6 @@ Copyright (C) 2008 O.Bogomaz
#include "..\lib\kolibri.h" #include "..\lib\kolibri.h"
#include "..\lib\random.h" #include "..\lib\random.h"
#include "..\lib\obj\libio.h"
#include "..\lib\obj\libimg.h" #include "..\lib\obj\libimg.h"
libimg_image menu; libimg_image menu;
@ -124,7 +123,6 @@ void main()
randomize(); randomize();
StartNewGame(); StartNewGame();
load_dll(libio, #libio_init,1);
load_dll(libimg, #libimg_init,1); load_dll(libimg, #libimg_init,1);
menu.load(abspath("menu.png")); menu.load(abspath("menu.png"));
road.load(abspath("road.png")); road.load(abspath("road.png"));