diff --git a/programs/develop/libraries/libs-dev/.test/006/test006.asm b/programs/develop/libraries/libs-dev/.test/006/test006.asm
index c639d607c7..3ffb277848 100644
--- a/programs/develop/libraries/libs-dev/.test/006/test006.asm
+++ b/programs/develop/libraries/libs-dev/.test/006/test006.asm
@@ -8,7 +8,7 @@ dd 1,START,I_END,MEM,STACKTOP,0,cur_dir_path
include '../../../../../proc32.inc'
include '../../../../../macros.inc'
include '../../../../../KOSfuncs.inc'
-include '../../../box_lib/load_lib.mac'
+include '../../../../../load_lib.mac'
include '../../../../../dll.inc'
include '../../libimg/libimg.inc'
@@ -28,7 +28,7 @@ else
end if
}
-@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc, dll.Load
+@use_library mem.Alloc,mem.Free,mem.ReAlloc, dll.Load
align 4
m1size dd 16*1024
@@ -251,18 +251,9 @@ lib_name_0 db 'buf2d.obj',0
system_dir_1 db '/sys/lib/'
lib_name_1 db 'libimg.obj',0
-err_message_found_lib0 db 'Sorry I cannot load library buf2d.obj',0
-err_message_found_lib1 db 'Sorry I cannot load library libimg.obj',0
-head_f_i:
-head_f_l db 'System error',0
-err_message_import0 db 'Error on load import library buf2d.obj',0
-err_message_import1 db 'Error on load import library libimg.obj',0
-
l_libs_start:
- lib0 l_libs lib_name_0, cur_dir_path, library_path, system_dir_0,\
- err_message_found_lib0, head_f_l, import_buf2d_lib,err_message_import0, head_f_i
- lib1 l_libs lib_name_1, cur_dir_path, library_path, system_dir_1,\
- err_message_found_lib1, head_f_l, import_libimg, err_message_import1, head_f_i
+ lib0 l_libs lib_name_0, library_path, system_dir_0, import_buf2d_lib
+ lib1 l_libs lib_name_1, library_path, system_dir_1, import_libimg
load_lib_end:
;---------------------------------------------------------------------
@@ -270,8 +261,6 @@ align 16
I_END:
rd 4096
STACKTOP:
-cur_dir_path:
- rb 4096
-library_path:
- rb 4096
+cur_dir_path rb 4096
+library_path rb 4096
MEM:
diff --git a/programs/develop/libraries/libs-dev/libimg/libimg.asm b/programs/develop/libraries/libs-dev/libimg/libimg.asm
index 7806b9a18a..db9b22069e 100644
--- a/programs/develop/libraries/libs-dev/libimg/libimg.asm
+++ b/programs/develop/libraries/libs-dev/libimg/libimg.asm
@@ -1,20 +1,20 @@
;;================================================================================================;;
;;//// libimg.asm //// (c) mike.dld, 2007-2008, (c) diamond, 2009, (c) dunkaist, 2011-2013 ///////;;
;;================================================================================================;;
-;; ;;
-;; This file is part of Common development libraries (Libs-Dev). ;;
-;; ;;
+;; ;;
+;; This file is part of Common development libraries (Libs-Dev). ;;
+;; ;;
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
-;; of the License, or (at your option) any later version. ;;
-;; ;;
+;; of the License, or (at your option) any later version. ;;
+;; ;;
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
-;; Lesser General Public License for more details. ;;
-;; ;;
+;; Lesser General Public License for more details. ;;
+;; ;;
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
-;; If not, see . ;;
-;; ;;
+;; If not, see . ;;
+;; ;;
;;================================================================================================;;
@@ -61,14 +61,14 @@ include 'blend.asm'
;;================================================================================================;;
proc lib_init ;///////////////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? Library entry point (called after library load) ;;
+;? Library entry point (called after library load) ;;
;;------------------------------------------------------------------------------------------------;;
-;> eax = pointer to memory allocation routine ;;
-;> ebx = pointer to memory freeing routine ;;
-;> ecx = pointer to memory reallocation routine ;;
-;> edx = pointer to library loading routine ;;
+;> eax = pointer to memory allocation routine ;;
+;> ebx = pointer to memory freeing routine ;;
+;> ecx = pointer to memory reallocation routine ;;
+;> edx = pointer to library loading routine ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = 1 (fail) / 0 (ok) (library initialization result) ;;
+;< eax = 1 (fail) / 0 (ok) (library initialization result) ;;
;;================================================================================================;;
mov [mem.alloc], eax
mov [mem.free], ebx
@@ -90,23 +90,23 @@ proc lib_init ;/////////////////////////////////////////////////////////////////
mov dword [img._.do_rgb.handlers + (Image.bpp16-1)*4], img._.do_rgb.bpp16.intel
@@:
- .ok: xor eax,eax
+ .ok: xor eax,eax
ret
endp
;;================================================================================================;;
proc img.is_img _data, _length ;//////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? --- TBD --- ;;
+;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;> --- TBD --- ;;
+;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;< --- TBD --- ;;
+;< --- TBD --- ;;
;;================================================================================================;;
push ebx
mov ebx, img.formats_table
@@: stdcall [ebx + FormatsTableEntry.Is], [_data], [_length]
- or eax, eax
+ or eax, eax
jnz @f
add ebx, sizeof.FormatsTableEntry
cmp dword[ebx], 0
@@ -119,11 +119,11 @@ endp
;;================================================================================================;;
proc img.info _data, _length ;////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? --- TBD --- ;;
+;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;> --- TBD --- ;;
+;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;< --- TBD --- ;;
+;< --- TBD --- ;;
;;================================================================================================;;
xor eax, eax
ret
@@ -132,59 +132,59 @@ endp
;;================================================================================================;;
proc img.from_file _filename ;////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? load file from disk and decode it ;;
+;? load file from disk and decode it ;;
;;------------------------------------------------------------------------------------------------;;
-;> [_filename] = file name as passed to libio ;;
+;> [_filename] = file name as passed to libio ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = 0 / pointer to image ;;
+;< eax = 0 / pointer to image ;;
;;================================================================================================;;
locals
- fd dd ?
- img_data_len dd ?
- img_data dd ? ; raw bytes
- img dd ? ; Image pointer
+ fd dd ?
+ img_data_len dd ?
+ img_data dd ? ; raw bytes
+ img dd ? ; Image pointer
endl
push ebx
- mov [img], 0
- invoke file.open, [_filename], O_READ
- mov [fd], eax
- test eax, eax
- jz .exit
- invoke file.size, [_filename]
- test eax, eax
- jnz .exit_close
- mov [img_data_len], ebx
- invoke mem.alloc, ebx
- test eax, eax
- jz .exit_close
- mov [img_data], eax
- invoke file.read, [fd], eax, [img_data_len]
- cmp eax, -1
- jz .exit_free_close
- cmp eax, [img_data_len]
- jnz .exit_free_close
- stdcall img.decode, [img_data], [img_data_len], 0
- test eax, eax
- jz .exit_free_close
- mov [img], eax
+ mov [img], 0
+ invoke file.open, [_filename], O_READ
+ mov [fd], eax
+ test eax, eax
+ jz .exit
+ invoke file.size, [_filename]
+ test eax, eax
+ jnz .exit_close
+ mov [img_data_len], ebx
+ invoke mem.alloc, ebx
+ test eax, eax
+ jz .exit_close
+ mov [img_data], eax
+ invoke file.read, [fd], eax, [img_data_len]
+ cmp eax, -1
+ jz .exit_free_close
+ cmp eax, [img_data_len]
+ jnz .exit_free_close
+ stdcall img.decode, [img_data], [img_data_len], 0
+ test eax, eax
+ jz .exit_free_close
+ mov [img], eax
.exit_free_close:
- invoke mem.free, [img_data]
+ invoke mem.free, [img_data]
.exit_close:
- invoke file.close, [fd]
- mov eax, [img]
+ invoke file.close, [fd]
+ mov eax, [img]
.exit:
pop ebx
- ret
+ ret
endp
;;================================================================================================;;
proc img.to_file _img, _filename ;////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? --- TBD --- ;;
+;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;> --- TBD --- ;;
+;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = false / true ;;
+;< eax = false / true ;;
;;================================================================================================;;
xor eax, eax
ret
@@ -193,11 +193,11 @@ endp
;;================================================================================================;;
proc img.from_rgb _rgb_data ;/////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? --- TBD --- ;;
+;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;> --- TBD --- ;;
+;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = 0 / pointer to image ;;
+;< eax = 0 / pointer to image ;;
;;================================================================================================;;
xor eax, eax
ret
@@ -206,17 +206,17 @@ endp
;;================================================================================================;;
proc img.to_rgb2 _img, _out ;/////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? decodes image data into RGB triplets and stores them where [_out] points to ;;
+;? decodes image data into RGB triplets and stores them where [_out] points to ;;
;;------------------------------------------------------------------------------------------------;;
-;> [_img] = pointer to source image ;;
-;> [_out] = where to store RGB triplets ;;
+;> [_img] = pointer to source image ;;
+;> [_out] = where to store RGB triplets ;;
;;------------------------------------------------------------------------------------------------;;
-;< none ;;
+;< none ;;
;;================================================================================================;;
push esi edi
mov esi, [_img]
stdcall img._.validate, esi
- or eax, eax
+ or eax, eax
jnz .ret
mov edi, [_out]
call img._.do_rgb
@@ -229,18 +229,18 @@ endp
proc img.to_rgb _img ;////////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? decodes image data into RGB triplets and returns pointer to memory area of following structure:;;
-;? width dd ? ;;
-;? height dd ? ;;
-;? rgb triplets ;;
+;? width dd ? ;;
+;? height dd ? ;;
+;? rgb triplets ;;
;;------------------------------------------------------------------------------------------------;;
-;> [_img] = pointer to source image ;;
+;> [_img] = pointer to source image ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = 0 / pointer to rgb_data (array of [rgb] triplets) ;;
+;< eax = 0 / pointer to rgb_data (array of [rgb] triplets) ;;
;;================================================================================================;;
push esi edi
mov esi, [_img]
stdcall img._.validate, esi
- or eax, eax
+ or eax, eax
jnz .error
mov esi, [_img]
@@ -248,8 +248,8 @@ proc img.to_rgb _img ;//////////////////////////////////////////////////////////
imul ecx, [esi + Image.Height]
lea eax, [ecx * 3 + 4 * 3]
invoke mem.alloc, eax
- or eax, eax
- jz .error
+ or eax, eax
+ jz .error
mov edi, eax
push eax
@@ -271,12 +271,12 @@ endp
;;================================================================================================;;
proc img._.do_rgb ;///////////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? decodes [esi + Image.Data] data into RGB triplets and stores them at [edi] ;;
+;? decodes [esi + Image.Data] data into RGB triplets and stores them at [edi] ;;
;;------------------------------------------------------------------------------------------------;;
-;> esi = pointer to source image ;;
-;> edi = pointer to memory to store RGB triplets ;;
+;> esi = pointer to source image ;;
+;> edi = pointer to memory to store RGB triplets ;;
;;------------------------------------------------------------------------------------------------;;
-;< none ;;
+;< none ;;
;;================================================================================================;;
mov ecx, [esi + Image.Width]
imul ecx, [esi + Image.Height]
@@ -290,7 +290,7 @@ align 16
mov ebx, [esi + Image.Palette]
mov esi, [esi + Image.Data]
sub ecx, 1
- jz .bpp8i.last
+ jz .bpp8i.last
@@:
movzx eax, byte [esi]
add esi, 1
@@ -338,7 +338,7 @@ align 16
.bpp15.intel:
push ebx ebp
sub ecx, 4
- jb .bpp15.tail
+ jb .bpp15.tail
align 16
.bpp15.intel.loop:
repeat 2
@@ -389,7 +389,7 @@ end repeat
jnb .bpp15.intel.loop
.bpp15.tail:
add ecx, 4
- jz .bpp15.done
+ jz .bpp15.done
@@:
movzx eax, word [esi]
mov ebx, eax
@@ -418,7 +418,7 @@ end repeat
.bpp15.amd:
push ebx ebp
sub ecx, 4
- jb .bpp15.tail
+ jb .bpp15.tail
align 16
.bpp15.amd.loop:
repeat 4
@@ -454,7 +454,7 @@ end repeat
.bpp16.intel:
push ebx ebp
sub ecx, 4
- jb .bpp16.tail
+ jb .bpp16.tail
align 16
.bpp16.intel.loop:
repeat 2
@@ -504,7 +504,7 @@ end repeat
jnb .bpp16.intel.loop
.bpp16.tail:
add ecx, 4
- jz .bpp16.done
+ jz .bpp16.done
@@:
movzx eax, word [esi]
mov ebx, eax
@@ -533,7 +533,7 @@ end repeat
.bpp16.amd:
push ebx ebp
sub ecx, 4
- jb .bpp16.tail
+ jb .bpp16.tail
align 16
.bpp16.amd.loop:
repeat 4
@@ -605,7 +605,7 @@ align 16
mov ecx, 7
.bpp1.begin:
xor eax, eax
- bt [esi], ecx
+ bt [esi], ecx
adc eax, 0
mov eax, [ebx + eax*4]
mov [edi], ax
@@ -711,13 +711,13 @@ endp
;;================================================================================================;;
proc img.decode _data, _length, _options ;////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? decodes loaded into memory graphic file ;;
+;? decodes loaded into memory graphic file ;;
;;------------------------------------------------------------------------------------------------;;
-;> [_data] = pointer to file in memory ;;
-;> [_length] = size in bytes of memory area pointed to by [_data] ;;
-;> [_options] = 0 / pointer to the structure of additional options ;;
+;> [_data] = pointer to file in memory ;;
+;> [_length] = size in bytes of memory area pointed to by [_data] ;;
+;> [_options] = 0 / pointer to the structure of additional options ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = 0 / pointer to image ;;
+;< eax = 0 / pointer to image ;;
;;================================================================================================;;
push ebx
mov ebx, [_length]
@@ -725,7 +725,7 @@ proc img.decode _data, _length, _options ;//////////////////////////////////////
jz .fail
mov ebx, img.formats_table
@@: stdcall [ebx + FormatsTableEntry.Is], [_data], [_length]
- or eax, eax
+ or eax, eax
jnz @f
add ebx, sizeof.FormatsTableEntry
cmp dword[ebx], eax ;0
@@ -741,111 +741,111 @@ proc img.decode _data, _length, _options ;//////////////////////////////////////
endp
;;================================================================================================;;
-proc img.encode _img, _common, _specific ;////////////////////////////////////////////////////////;;
+proc img.encode uses ebx, _img, _common, _specific ;////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? encode image to some format ;;
+;? encode image to some format ;;
;;------------------------------------------------------------------------------------------------;;
-;> [_img] = pointer to input image ;;
-;> [_common] = some most important/common options ;;
-; 0x00 : byte : format id (defined in libimg.inc) ;;
-; 0x01 : byte : fast encoding (0) / best compression ratio (255) ;;
-; 0 : store uncompressed data (if supported both by the format and libimg) ;;
-; 1 - 255 : use compression, if supported ;;
-; this option may be ignored if any format specific options are defined ;;
-; i.e. 0 here will be ignored if particular compression algorithm is specified ;;
-; 0x02 : byte : flags (bitfield) ;;
-; 0x01 : return an error if format specific conditions cannot be met ;;
-; 0x02 : preserve current bit depth. means 8bpp/16bpp/24bpp and so on ;;
-; 0x04 : delete alpha channel, if any ;;
-; 0x08 : flush alpha channel with 0xff, if any; add it if none ;;
-; 0x03 : byte : reserved, must be 0 ;;
-;> [_specific] = 0 / pointer to the structure of format specific options ;;
-; see .inc for description ;;
+;> [_img] = pointer to input image ;;
+;> [_common] = some most important/common options ;;
+; 0x00 : byte : format id (defined in libimg.inc) ;;
+; 0x01 : byte : fast encoding (0) / best compression ratio (255) ;;
+; 0 : store uncompressed data (if supported both by the format and libimg) ;;
+; 1 - 255 : use compression, if supported ;;
+; this option may be ignored if any format specific options are defined ;;
+; i.e. 0 here will be ignored if particular compression algorithm is specified ;;
+; 0x02 : byte : flags (bitfield) ;;
+; 0x01 : return an error if format specific conditions cannot be met ;;
+; 0x02 : preserve current bit depth. means 8bpp/16bpp/24bpp and so on ;;
+; 0x04 : delete alpha channel, if any ;;
+; 0x08 : flush alpha channel with 0xff, if any; add it if none ;;
+; 0x03 : byte : reserved, must be 0 ;;
+;> [_specific] = 0 / pointer to the structure of format specific options ;;
+; see .inc for description ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = 0 / pointer to encoded data ;;
-;< ecx = error code / the size of encoded data ;;
-; 1 : out of memory ;;
-; 2 : format is not supported ;;
-; 3 : specific conditions cannot be satisfied ;;
-; 4 : bit depth cannot be preserved ;;
+;< eax = 0 / pointer to encoded data ;;
+;< ecx = error code / the size of encoded data ;;
+; 1 : out of memory ;;
+; 2 : format is not supported ;;
+; 3 : specific conditions cannot be satisfied ;;
+; 4 : bit depth cannot be preserved ;;
;;================================================================================================;;
- mov ebx, [_img]
+ mov ebx, [_img]
- movzx eax, byte[_common]
- dec eax
- imul eax, sizeof.FormatsTableEntry
- add eax, FormatsTableEntry.Capabilities
- add eax, img.formats_table
- mov eax, [eax]
- test eax, 1 ; is encoding to this format supported at all?
- jnz @f
- mov ecx, LIBIMG_ERROR_FORMAT
- jmp .error
+ movzx eax, byte[_common]
+ dec eax
+ imul eax, sizeof.FormatsTableEntry
+ add eax, FormatsTableEntry.Capabilities
+ add eax, img.formats_table
+ mov eax, [eax]
+ test eax, 1 ; is encoding to this format supported at all?
+ jnz @f
+ mov ecx, LIBIMG_ERROR_FORMAT
+ jmp .error
@@:
- mov ecx, [ebx + Image.Type]
- mov edx, 1
- shl edx, cl
- test eax, edx
- jnz .bit_depth_ok
- test byte[_common+2], LIBIMG_ENCODE_STRICT_BIT_DEPTH
- jz @f
- mov ecx, LIBIMG_ERROR_BIT_DEPTH
- jmp .error
+ mov ecx, [ebx + Image.Type]
+ mov edx, 1
+ shl edx, cl
+ test eax, edx
+ jnz .bit_depth_ok
+ test byte[_common+2], LIBIMG_ENCODE_STRICT_BIT_DEPTH
+ jz @f
+ mov ecx, LIBIMG_ERROR_BIT_DEPTH
+ jmp .error
@@:
- mov edx, 1 SHL Image.bpp24
- test eax, edx
- jnz @f
- mov ecx, LIBIMG_ERROR_BIT_DEPTH
- jmp .error
+ mov edx, 1 SHL Image.bpp24
+ test eax, edx
+ jnz @f
+ mov ecx, LIBIMG_ERROR_BIT_DEPTH
+ jmp .error
@@:
- stdcall img.create, [ebx + Image.Width], [ebx + Image.Height], Image.bpp24
- test eax, eax
- jnz @f
- mov ecx, LIBIMG_ERROR_OUT_OF_MEMORY
- jmp .error
+ stdcall img.create, [ebx + Image.Width], [ebx + Image.Height], Image.bpp24
+ test eax, eax
+ jnz @f
+ mov ecx, LIBIMG_ERROR_OUT_OF_MEMORY
+ jmp .error
@@:
- push eax
- stdcall img.to_rgb2, ebx, [eax + Image.Data]
- pop ebx
+ push eax
+ stdcall img.to_rgb2, ebx, [eax + Image.Data]
+ pop ebx
.bit_depth_ok:
- movzx eax, byte[_common]
- dec eax
- imul eax, sizeof.FormatsTableEntry
- add eax, FormatsTableEntry.Encode
- add eax, img.formats_table
- mov eax, [eax]
- stdcall eax, [_img], [_common], [_specific]
- push eax ecx
- cmp ebx, [_img]
- je @f
- stdcall img.destroy, ebx
+ movzx eax, byte[_common]
+ dec eax
+ imul eax, sizeof.FormatsTableEntry
+ add eax, FormatsTableEntry.Encode
+ add eax, img.formats_table
+ mov eax, [eax]
+ stdcall eax, [_img], [_common], [_specific]
+ push eax ecx
+ cmp ebx, [_img]
+ je @f
+ stdcall img.destroy, ebx
@@:
- pop ecx eax
- jmp .quit
+ pop ecx eax
+ jmp .quit
.error:
- xor eax, eax
+ xor eax, eax
.quit:
- ret
+ ret
endp
;;================================================================================================;;
proc img.create _width, _height, _type ;//////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? creates an Image structure and initializes some its fields ;;
+;? creates an Image structure and initializes some its fields ;;
;;------------------------------------------------------------------------------------------------;;
-;> [_width] = width of an image in pixels ;;
-;> [_height] = height of an image in pixels ;;
-;> [_type] = one of the Image.bppN constants from libimg.inc ;;
+;> [_width] = width of an image in pixels ;;
+;> [_height] = height of an image in pixels ;;
+;> [_type] = one of the Image.bppN constants from libimg.inc ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = 0 / pointer to image ;;
+;< eax = 0 / pointer to image ;;
;;================================================================================================;;
push ecx
stdcall img._.new
- or eax, eax
- jz .error
+ or eax, eax
+ jz .error
mov ecx, [_type]
mov [eax + Image.Type], ecx
@@ -853,14 +853,14 @@ proc img.create _width, _height, _type ;////////////////////////////////////////
push eax
stdcall img.resize_data, eax, [_width], [_height]
- or eax, eax
- jz .error.2
+ or eax, eax
+ jz .error.2
pop eax
jmp .ret
.error.2:
-; pop eax
+; pop eax
stdcall img._.delete; eax
xor eax, eax
@@ -873,23 +873,23 @@ endp
;;================================================================================================;;
proc img.destroy.layer _img ;/////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? frees memory occupied by an image and all the memory regions its fields point to ;;
-;? for image sequences deletes only one frame and fixes Previous/Next pointers ;;
+;? frees memory occupied by an image and all the memory regions its fields point to ;;
+;? for image sequences deletes only one frame and fixes Previous/Next pointers ;;
;;------------------------------------------------------------------------------------------------;;
-;> [_img] = pointer to image ;;
+;> [_img] = pointer to image ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = 0 (fail) / 1 (success) ;;
+;< eax = 0 (fail) / 1 (success) ;;
;;================================================================================================;;
mov eax, [_img]
mov edx, [eax + Image.Previous]
test edx, edx
- jz @f
+ jz @f
push [eax + Image.Next]
pop [edx + Image.Next]
@@:
mov edx, [eax + Image.Next]
test edx, edx
- jz @f
+ jz @f
push [eax + Image.Previous]
pop [edx + Image.Previous]
@@:
@@ -900,19 +900,19 @@ endp
;;================================================================================================;;
proc img.destroy _img ;///////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? frees memory occupied by an image and all the memory regions its fields point to ;;
-;? follows Previous/Next pointers and deletes all the images in sequence ;;
+;? frees memory occupied by an image and all the memory regions its fields point to ;;
+;? follows Previous/Next pointers and deletes all the images in sequence ;;
;;------------------------------------------------------------------------------------------------;;
-;> [_img] = pointer to image ;;
+;> [_img] = pointer to image ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = 0 (fail) / 1 (success) ;;
+;< eax = 0 (fail) / 1 (success) ;;
;;================================================================================================;;
push 1
mov eax, [_img]
mov eax, [eax + Image.Previous]
.destroy_prev_loop:
test eax, eax
- jz .destroy_prev_done
+ jz .destroy_prev_done
pushd [eax + Image.Previous]
stdcall img._.delete, eax
test eax, eax
@@ -940,29 +940,29 @@ endp
;;================================================================================================;;
proc img.count _img ;/////////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? Get number of images in the list (e.g. in animated GIF file) ;;
+;? Get number of images in the list (e.g. in animated GIF file) ;;
;;------------------------------------------------------------------------------------------------;;
-;> _img = pointer to image ;;
+;> _img = pointer to image ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = -1 (fail) / >0 (ok) ;;
+;< eax = -1 (fail) / >0 (ok) ;;
;;================================================================================================;;
push ecx edx
mov edx, [_img]
stdcall img._.validate, edx
- or eax, eax
+ or eax, eax
jnz .error
@@: mov eax, [edx + Image.Previous]
- or eax, eax
- jz @f
+ or eax, eax
+ jz @f
mov edx, eax
jmp @b
@@: xor ecx, ecx
@@: inc ecx
mov eax, [edx + Image.Next]
- or eax, eax
- jz .exit
+ or eax, eax
+ jz .exit
mov edx, eax
jmp @b
@@ -972,7 +972,7 @@ proc img.count _img ;///////////////////////////////////////////////////////////
ret
.error:
- or eax, -1
+ or eax, -1
pop edx ecx
ret
endp
@@ -982,11 +982,11 @@ endp
;;================================================================================================;;
proc img.lock_bits _img, _start_line, _end_line ;/////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? --- TBD --- ;;
+;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;> --- TBD --- ;;
+;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = 0 / pointer to bits ;;
+;< eax = 0 / pointer to bits ;;
;;================================================================================================;;
xor eax, eax
ret
@@ -995,11 +995,11 @@ endp
;;================================================================================================;;
proc img.unlock_bits _img, _lock ;////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? --- TBD --- ;;
+;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;> --- TBD --- ;;
+;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = false / true ;;
+;< eax = false / true ;;
;;================================================================================================;;
xor eax, eax
ret
@@ -1008,12 +1008,12 @@ endp
;;================================================================================================;;
proc img.flip.layer _img, _flip_kind ;////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? Flip image layer ;;
+;? Flip image layer ;;
;;------------------------------------------------------------------------------------------------;;
-;> _img = pointer to image ;;
-;> _flip_kind = one of FLIP_* constants ;;
+;> _img = pointer to image ;;
+;> _flip_kind = one of FLIP_* constants ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = false / true ;;
+;< eax = false / true ;;
;;================================================================================================;;
locals
scanline_len dd ?
@@ -1022,7 +1022,7 @@ endl
push ebx esi edi
mov ebx, [_img]
stdcall img._.validate, ebx
- or eax, eax
+ or eax, eax
jnz .error
mov ecx, [ebx + Image.Height]
@@ -1031,7 +1031,7 @@ endl
mov [scanline_len], eax
test [_flip_kind], FLIP_VERTICAL
- jz .dont_flip_vert
+ jz .dont_flip_vert
imul eax, ecx
sub eax, [scanline_len]
@@ -1047,7 +1047,7 @@ endl
shr ecx, 2
@@:
dec ecx
- js @f
+ js @f
mov eax, [esi]
xchg eax, [edi]
mov [esi], eax
@@ -1058,7 +1058,7 @@ endl
pop ecx
and ecx, 3
- jz .cont_line_vert
+ jz .cont_line_vert
@@:
mov al, [esi]
xchg al, [edi]
@@ -1079,7 +1079,7 @@ endl
.dont_flip_vert:
test [_flip_kind], FLIP_HORIZONTAL
- jz .exit
+ jz .exit
mov ecx, [ebx + Image.Height]
mov eax, [ebx + Image.Type]
@@ -1124,7 +1124,7 @@ endl
add esi, 2
sub edi, 2
sub ecx, 2
- ja @b
+ ja @b
pop edi esi ecx
add esi, [scanline_len]
@@ -1178,7 +1178,7 @@ endl
add esi, 3
sub edi, 3
sub ecx, 2
- ja @b
+ ja @b
pop edi esi ecx
add esi, [scanline_len]
@@ -1202,8 +1202,8 @@ endl
mov ebx, [ebx + Image.Width]
shr ebx, 1
.bpp1_horz.bit:
- bt [edi], edx
- jc @f
+ bt [edi], edx
+ jc @f
btr [esi], eax
jmp .bpp1_horz.right
@@:
@@ -1265,7 +1265,7 @@ endl
shl ebx, cl
not bh
and bh, [esi]
- or bl, bh
+ or bl, bh
mov bh, [esi]
mov [esi], bl
shr ebx, 8
@@ -1278,7 +1278,7 @@ endl
shl ebx, cl
not bh
and bh, [edi]
- or bl, bh
+ or bl, bh
mov [edi], bl
pop ecx ebx
.bpp2i_horz.pixel_done:
@@ -1331,7 +1331,7 @@ endl
shl ebx, cl
not bh
and bh, [esi]
- or bl, bh
+ or bl, bh
mov bh, [esi]
mov [esi], bl
shr ebx, 8
@@ -1343,7 +1343,7 @@ endl
shl ebx, cl
not bh
and bh, [edi]
- or bl, bh
+ or bl, bh
mov [edi], bl
pop ecx ebx
.bpp4i_horz.pixel_done:
@@ -1383,19 +1383,19 @@ endp
;;================================================================================================;;
proc img.flip _img, _flip_kind ;//////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? Flip all layers of image ;;
+;? Flip all layers of image ;;
;;------------------------------------------------------------------------------------------------;;
-;> _img = pointer to image ;;
-;> _flip_kind = one of FLIP_* constants ;;
+;> _img = pointer to image ;;
+;> _flip_kind = one of FLIP_* constants ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = false / true ;;
+;< eax = false / true ;;
;;================================================================================================;;
push 1
mov ebx, [_img]
@@:
mov eax, [ebx + Image.Previous]
test eax, eax
- jz .loop
+ jz .loop
mov ebx, eax
jmp @b
.loop:
@@ -1414,19 +1414,19 @@ endp
;;================================================================================================;;
proc img.rotate.layer _img, _rotate_kind ;////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? Rotate image layer ;;
+;? Rotate image layer ;;
;;------------------------------------------------------------------------------------------------;;
-;> _img = pointer to image ;;
-;> _rotate_kind = one of ROTATE_* constants ;;
+;> _img = pointer to image ;;
+;> _rotate_kind = one of ROTATE_* constants ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = false / true ;;
+;< eax = false / true ;;
;;================================================================================================;;
locals
scanline_len_old dd ?
scanline_len_new dd ?
scanline_pixels_new dd ?
- line_buffer dd ?
- pixels_ptr dd ?
+ line_buffer dd ?
+ pixels_ptr dd ?
endl
mov [line_buffer], 0
@@ -1434,15 +1434,15 @@ endl
push ebx esi edi
mov ebx, [_img]
stdcall img._.validate, ebx
- or eax, eax
+ or eax, eax
jnz .error
cmp [_rotate_kind], ROTATE_90_CCW
- je .rotate_ccw_low
+ je .rotate_ccw_low
cmp [_rotate_kind], ROTATE_90_CW
- je .rotate_cw_low
+ je .rotate_cw_low
cmp [_rotate_kind], ROTATE_180
- je .flip
+ je .flip
jmp .exit
.rotate_ccw_low:
@@ -1452,8 +1452,8 @@ endl
mov [scanline_len_new], eax
invoke mem.alloc, eax
- or eax, eax
- jz .error
+ or eax, eax
+ jz .error
mov [line_buffer], eax
mov eax, [ebx + Image.Width]
@@ -1467,23 +1467,23 @@ endl
mov [pixels_ptr], eax
cmp [ebx + Image.Type], Image.bpp1
- jz .rotate_ccw1
+ jz .rotate_ccw1
cmp [ebx + Image.Type], Image.bpp2i
- jz .rotate_ccw2i
+ jz .rotate_ccw2i
cmp [ebx + Image.Type], Image.bpp4i
- jz .rotate_ccw4i
+ jz .rotate_ccw4i
cmp [ebx + Image.Type], Image.bpp8i
- jz .rotate_ccw8ig
+ jz .rotate_ccw8ig
cmp [ebx + Image.Type], Image.bpp8g
- jz .rotate_ccw8ig
+ jz .rotate_ccw8ig
cmp [ebx + Image.Type], Image.bpp24
- jz .rotate_ccw24
+ jz .rotate_ccw24
cmp [ebx + Image.Type], Image.bpp32
- jz .rotate_ccw32
+ jz .rotate_ccw32
.next_column_ccw_low1x:
dec ecx
- js .exchange_dims
+ js .exchange_dims
push ecx
mov edx, [scanline_len_old]
@@ -1531,7 +1531,7 @@ endl
.rotate_ccw32:
.next_column_ccw_low:
dec ecx
- js .exchange_dims
+ js .exchange_dims
push ecx
mov edx, [scanline_len_old]
@@ -1570,7 +1570,7 @@ endl
.rotate_ccw8ig:
.next_column_ccw_low8ig:
dec ecx
- js .exchange_dims
+ js .exchange_dims
push ecx
mov edx, [scanline_len_old]
@@ -1618,7 +1618,7 @@ endl
.rotate_ccw24:
.next_column_ccw_low24:
dec ecx
- js .exchange_dims
+ js .exchange_dims
push ecx
mov edx, [scanline_len_old]
@@ -1673,12 +1673,12 @@ endl
add eax, 7
shr eax, 3
imul eax, [ebx + Image.Width]
- push eax ; save new data size
+ push eax ; save new data size
invoke mem.alloc, eax
- or eax, eax
- jz .error
- push eax ; save pointer to new data
+ or eax, eax
+ jz .error
+ push eax ; save pointer to new data
mov ecx, [ebx + Image.Width]
and ecx, 7
@@ -1694,7 +1694,7 @@ endl
add esi, edx
.rotate_ccw1.begin:
- bt [esi], ecx
+ bt [esi], ecx
jc .rotate_ccw1.one
.rotate_ccw1.zero:
btr [edi], eax
@@ -1727,9 +1727,9 @@ endl
add esi, edx
jmp .rotate_ccw1.begin
.rotate_ccw1.quit:
- pop esi ; get pointer to new data
+ pop esi ; get pointer to new data
mov edi, [ebx + Image.Data]
- pop ecx ; get new data size
+ pop ecx ; get new data size
rep movsb
invoke mem.free, esi
pop edx ecx
@@ -1743,12 +1743,12 @@ endl
add eax, 3
shr eax, 2
imul eax, [ebx + Image.Width]
- push eax ; save new data size
+ push eax ; save new data size
invoke mem.alloc, eax
- or eax, eax
- jz .error
- push eax ; save pointer to new data
+ or eax, eax
+ jz .error
+ push eax ; save pointer to new data
mov ecx, [ebx + Image.Width]
and ecx, 3
@@ -1777,7 +1777,7 @@ endl
shl ebx, cl
not bh
and bh, [edi]
- or bl, bh
+ or bl, bh
mov [edi], bl
pop ecx ebx
@@ -1806,9 +1806,9 @@ endl
add esi, edx
jmp .rotate_ccw2i.begin
.rotate_ccw2i.quit:
- pop esi ; get pointer to new data
+ pop esi ; get pointer to new data
mov edi, [ebx + Image.Data]
- pop ecx ; get new data size
+ pop ecx ; get new data size
rep movsb
invoke mem.free, esi
pop edx ecx
@@ -1822,12 +1822,12 @@ endl
add eax, 1
shr eax, 1
imul eax, [ebx + Image.Width]
- push eax ; save new data size
+ push eax ; save new data size
invoke mem.alloc, eax
- or eax, eax
- jz .error
- push eax ; save pointer to new data
+ or eax, eax
+ jz .error
+ push eax ; save pointer to new data
mov ecx, [ebx + Image.Width]
and ecx, 1
@@ -1855,7 +1855,7 @@ endl
shl ebx, cl
not bh
and bh, [edi]
- or bl, bh
+ or bl, bh
mov [edi], bl
pop ecx ebx
@@ -1884,9 +1884,9 @@ endl
add esi, edx
jmp .rotate_ccw4i.begin
.rotate_ccw4i.quit:
- pop esi ; get pointer to new data
+ pop esi ; get pointer to new data
mov edi, [ebx + Image.Data]
- pop ecx ; get new data size
+ pop ecx ; get new data size
rep movsb
invoke mem.free, esi
pop edx ecx
@@ -1901,8 +1901,8 @@ endl
mov [scanline_len_new], eax
invoke mem.alloc, eax
- or eax, eax
- jz .error
+ or eax, eax
+ jz .error
mov [line_buffer], eax
mov eax, [ebx + Image.Width]
@@ -1916,23 +1916,23 @@ endl
mov [pixels_ptr], eax
cmp [ebx + Image.Type], Image.bpp1
- jz .rotate_cw1
+ jz .rotate_cw1
cmp [ebx + Image.Type], Image.bpp2i
- jz .rotate_cw2i
+ jz .rotate_cw2i
cmp [ebx + Image.Type], Image.bpp4i
- jz .rotate_cw4i
+ jz .rotate_cw4i
cmp [ebx + Image.Type], Image.bpp8i
- jz .rotate_cw8ig
+ jz .rotate_cw8ig
cmp [ebx + Image.Type], Image.bpp8g
- jz .rotate_cw8ig
+ jz .rotate_cw8ig
cmp [ebx + Image.Type], Image.bpp24
- jz .rotate_cw24
+ jz .rotate_cw24
cmp [ebx + Image.Type], Image.bpp32
- jz .rotate_cw32
+ jz .rotate_cw32
.next_column_cw_low1x:
dec ecx
- js .exchange_dims
+ js .exchange_dims
push ecx
mov edx, [scanline_len_old]
@@ -1982,7 +1982,7 @@ endl
.rotate_cw32:
.next_column_cw_low:
dec ecx
- js .exchange_dims
+ js .exchange_dims
push ecx
mov edx, [scanline_len_old]
@@ -2024,7 +2024,7 @@ endl
.rotate_cw8ig:
.next_column_cw_low8ig:
dec ecx
- js .exchange_dims
+ js .exchange_dims
push ecx
mov edx, [scanline_len_old]
@@ -2074,7 +2074,7 @@ endl
.rotate_cw24:
.next_column_cw_low24:
dec ecx
- js .exchange_dims
+ js .exchange_dims
push ecx
mov edx, [scanline_len_old]
@@ -2133,12 +2133,12 @@ endl
add eax, 7
shr eax, 3
imul [ebx + Image.Width]
- push eax ; save new data size
+ push eax ; save new data size
invoke mem.alloc, eax
- or eax, eax
- jz .error
- push eax ; save pointer to new data
+ or eax, eax
+ jz .error
+ push eax ; save pointer to new data
mov edi, eax
mov esi, [ebx + Image.Data]
@@ -2151,7 +2151,7 @@ endl
mov edx, 0
.rotate_cw1.begin:
- bt [esi], ecx
+ bt [esi], ecx
jc .rotate_cw1.one
.rotate_cw1.zero:
btr [edi], eax
@@ -2161,7 +2161,7 @@ endl
@@:
sub esi, [scanline_len_old]
dec [scanline_pixels_new]
- jz .rotate_cw1.end_of_line
+ jz .rotate_cw1.end_of_line
sub eax, 1
adc edi, 0
and eax, 7
@@ -2169,7 +2169,7 @@ endl
.rotate_cw1.end_of_line:
inc edi
mov eax, [ebx + Image.Height]
- mov [scanline_pixels_new], eax
+ mov [scanline_pixels_new], eax
mov eax, 7
dec ecx
jns @f
@@ -2185,10 +2185,10 @@ endl
add esi, edx
jmp .rotate_cw1.begin
.rotate_cw1.quit:
- pop eax ; get pointer to new data
+ pop eax ; get pointer to new data
mov esi, eax
mov edi, [ebx + Image.Data]
- pop ecx ; get new data size
+ pop ecx ; get new data size
rep movsb
invoke mem.free, eax
pop edx ecx
@@ -2202,12 +2202,12 @@ endl
add eax, 3
shr eax, 2
imul [ebx + Image.Width]
- push eax ; save new data size
+ push eax ; save new data size
invoke mem.alloc, eax
- or eax, eax
- jz .error
- push eax ; save pointer to new data
+ or eax, eax
+ jz .error
+ push eax ; save pointer to new data
mov edi, eax
mov esi, [ebx + Image.Data]
@@ -2233,13 +2233,13 @@ endl
shl ebx, cl
not bh
and bh, [edi]
- or bl, bh
+ or bl, bh
mov [edi], bl
pop ecx ebx
sub esi, [scanline_len_old]
dec [scanline_pixels_new]
- jz .rotate_cw2i.end_of_line
+ jz .rotate_cw2i.end_of_line
sub eax, 1
adc edi, 0
and eax, 3
@@ -2247,7 +2247,7 @@ endl
.rotate_cw2i.end_of_line:
inc edi
mov eax, [ebx + Image.Height]
- mov [scanline_pixels_new], eax
+ mov [scanline_pixels_new], eax
mov eax, 3
dec ecx
jns @f
@@ -2263,10 +2263,10 @@ endl
add esi, edx
jmp .rotate_cw2i.begin
.rotate_cw2i.quit:
- pop eax ; get pointer to new data
+ pop eax ; get pointer to new data
mov esi, eax
mov edi, [ebx + Image.Data]
- pop ecx ; get new data size
+ pop ecx ; get new data size
rep movsb
invoke mem.free, eax
pop edx ecx
@@ -2280,12 +2280,12 @@ endl
add eax, 1
shr eax, 1
imul [ebx + Image.Width]
- push eax ; save new data size
+ push eax ; save new data size
invoke mem.alloc, eax
- or eax, eax
- jz .error
- push eax ; save pointer to new data
+ or eax, eax
+ jz .error
+ push eax ; save pointer to new data
mov edi, eax
mov esi, [ebx + Image.Data]
@@ -2310,13 +2310,13 @@ endl
shl ebx, cl
not bh
and bh, [edi]
- or bl, bh
+ or bl, bh
mov [edi], bl
pop ecx ebx
sub esi, [scanline_len_old]
dec [scanline_pixels_new]
- jz .rotate_cw4i.end_of_line
+ jz .rotate_cw4i.end_of_line
sub eax, 1
adc edi, 0
and eax, 1
@@ -2324,7 +2324,7 @@ endl
.rotate_cw4i.end_of_line:
inc edi
mov eax, [ebx + Image.Height]
- mov [scanline_pixels_new], eax
+ mov [scanline_pixels_new], eax
mov eax, 1
dec ecx
jns @f
@@ -2340,10 +2340,10 @@ endl
add esi, edx
jmp .rotate_cw4i.begin
.rotate_cw4i.quit:
- pop eax ; get pointer to new data
+ pop eax ; get pointer to new data
mov esi, eax
mov edi, [ebx + Image.Data]
- pop ecx ; get new data size
+ pop ecx ; get new data size
rep movsb
invoke mem.free, eax
pop edx ecx
@@ -2353,7 +2353,7 @@ endl
.flip:
stdcall img.flip.layer, [_img], FLIP_VERTICAL
test eax, eax
- jz .error
+ jz .error
jmp .exit
.exchange_dims:
@@ -2377,19 +2377,19 @@ endp
;;================================================================================================;;
proc img.rotate _img, _rotate_kind ;//////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? Rotate all layers of image ;;
+;? Rotate all layers of image ;;
;;------------------------------------------------------------------------------------------------;;
-;> _img = pointer to image ;;
-;> _rotate_kind = one of ROTATE_* constants ;;
+;> _img = pointer to image ;;
+;> _rotate_kind = one of ROTATE_* constants ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = false / true ;;
+;< eax = false / true ;;
;;================================================================================================;;
push 1
mov ebx, [_img]
@@:
mov eax, [ebx + Image.Previous]
test eax, eax
- jz .loop
+ jz .loop
mov ebx, eax
jmp @b
.loop:
@@ -2408,17 +2408,17 @@ endp
;;================================================================================================;;
proc img.draw _img, _x, _y, _width, _height, _xpos, _ypos ;///////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? Draw image in the window ;;
+;? Draw image in the window ;;
;;------------------------------------------------------------------------------------------------;;
-;> _img = pointer to image ;;
-;>_x = x-coordinate in the window ;;
-;>_y = y-coordinate in the window ;;
-;>_width = maximum width to draw ;;
-;>_height = maximum height to draw ;;
-;>_xpos = offset in image by x-axis ;;
-;>_ypos = offset in image by y-axis ;;
+;> _img = pointer to image ;;
+;>_x = x-coordinate in the window ;;
+;>_y = y-coordinate in the window ;;
+;>_width = maximum width to draw ;;
+;>_height = maximum height to draw ;;
+;>_xpos = offset in image by x-axis ;;
+;>_ypos = offset in image by y-axis ;;
;;------------------------------------------------------------------------------------------------;;
-;< no return value ;;
+;< no return value ;;
;;================================================================================================;;
push ebx esi edi
mov ebx, [_img]
@@ -2429,14 +2429,14 @@ proc img.draw _img, _x, _y, _width, _height, _xpos, _ypos ;/////////////////////
sub ecx, [_xpos]
jbe .done
cmp ecx, [_width]
- jb @f
+ jb @f
mov ecx, [_width]
@@:
mov edx, [ebx + Image.Height]
sub edx, [_ypos]
jbe .done
cmp edx, [_height]
- jb @f
+ jb @f
mov edx, [_height]
@@:
mov eax, [ebx + Image.Width]
@@ -2471,26 +2471,26 @@ endp
align 4
img.formats_table:
- .bmp dd LIBIMG_FORMAT_BMP, img.is.bmp, img.decode.bmp, img.encode.bmp, 1 + (1 SHL Image.bpp24) + (1 SHL Image.bpp32)
- .ico dd LIBIMG_FORMAT_ICO, img.is.ico, img.decode.ico_cur, img.encode.ico, 0
- .cur dd LIBIMG_FORMAT_CUR, img.is.cur, img.decode.ico_cur, img.encode.cur, 0
- .gif dd LIBIMG_FORMAT_GIF, img.is.gif, img.decode.gif, img.encode.gif, 0
- .png dd LIBIMG_FORMAT_PNG, img.is.png, img.decode.png, img.encode.png, 1 + (1 SHL Image.bpp24)
- .jpg dd LIBIMG_FORMAT_JPEG, img.is.jpg, img.decode.jpg, img.encode.jpg, 0
- .tga dd LIBIMG_FORMAT_TGA, img.is.tga, img.decode.tga, img.encode.tga, 0
- .pcx dd LIBIMG_FORMAT_PCX, img.is.pcx, img.decode.pcx, img.encode.pcx, 0
- .xcf dd LIBIMG_FORMAT_XCF, img.is.xcf, img.decode.xcf, img.encode.xcf, 0
- .tiff dd LIBIMG_FORMAT_TIFF, img.is.tiff, img.decode.tiff, img.encode.tiff,0
- .pnm dd LIBIMG_FORMAT_PNM, img.is.pnm, img.decode.pnm, img.encode.pnm, 1 + (1 SHL Image.bpp1) + (1 SHL Image.bpp8g) + (1 SHL Image.bpp24)
- .wbmp dd LIBIMG_FORMAT_WBMP, img.is.wbmp, img.decode.wbmp, img.encode.wbmp,0
- .xbm dd LIBIMG_FORMAT_XBM, img.is.xbm, img.decode.xbm, img.encode.xbm, 0
- .z80 dd LIBIMG_FORMAT_Z80, img.is.z80, img.decode.z80, img.encode.z80, 0 ;this must be the last entry as there are no signatures in z80 screens at all
- dd 0
+ .bmp dd LIBIMG_FORMAT_BMP, img.is.bmp, img.decode.bmp, img.encode.bmp, 1 + (1 SHL Image.bpp24) + (1 SHL Image.bpp32)
+ .ico dd LIBIMG_FORMAT_ICO, img.is.ico, img.decode.ico_cur, img.encode.ico, 0
+ .cur dd LIBIMG_FORMAT_CUR, img.is.cur, img.decode.ico_cur, img.encode.cur, 0
+ .gif dd LIBIMG_FORMAT_GIF, img.is.gif, img.decode.gif, img.encode.gif, 0
+ .png dd LIBIMG_FORMAT_PNG, img.is.png, img.decode.png, img.encode.png, 1 + (1 SHL Image.bpp24)
+ .jpg dd LIBIMG_FORMAT_JPEG, img.is.jpg, img.decode.jpg, img.encode.jpg, 0
+ .tga dd LIBIMG_FORMAT_TGA, img.is.tga, img.decode.tga, img.encode.tga, 0
+ .pcx dd LIBIMG_FORMAT_PCX, img.is.pcx, img.decode.pcx, img.encode.pcx, 0
+ .xcf dd LIBIMG_FORMAT_XCF, img.is.xcf, img.decode.xcf, img.encode.xcf, 0
+ .tiff dd LIBIMG_FORMAT_TIFF, img.is.tiff, img.decode.tiff, img.encode.tiff,0
+ .pnm dd LIBIMG_FORMAT_PNM, img.is.pnm, img.decode.pnm, img.encode.pnm, 1 + (1 SHL Image.bpp1) + (1 SHL Image.bpp8g) + (1 SHL Image.bpp24)
+ .wbmp dd LIBIMG_FORMAT_WBMP, img.is.wbmp, img.decode.wbmp, img.encode.wbmp,0
+ .xbm dd LIBIMG_FORMAT_XBM, img.is.xbm, img.decode.xbm, img.encode.xbm, 0
+ .z80 dd LIBIMG_FORMAT_Z80, img.is.z80, img.decode.z80, img.encode.z80, 0 ;this must be the last entry as there are no signatures in z80 screens at all
+ dd 0
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
-;! Below are private procs you should never call directly from your code ;;
+;! Below are private procs you should never call directly from your code ;;
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
@@ -2499,11 +2499,11 @@ img.formats_table:
;;================================================================================================;;
proc img._.validate, _img ;///////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? --- TBD --- ;;
+;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;> --- TBD --- ;;
+;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;< --- TBD --- ;;
+;< --- TBD --- ;;
;;================================================================================================;;
xor eax, eax
ret
@@ -2512,15 +2512,15 @@ endp
;;================================================================================================;;
proc img._.new ;//////////////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? --- TBD --- ;;
+;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;> --- TBD --- ;;
+;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = 0 / pointer to image ;;
+;< eax = 0 / pointer to image ;;
;;================================================================================================;;
invoke mem.alloc, sizeof.Image
test eax, eax
- jz @f
+ jz @f
push ecx
xor ecx, ecx
mov [eax + Image.Data], ecx
@@ -2537,21 +2537,21 @@ endp
;;================================================================================================;;
proc img._.delete _img ;//////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? --- TBD --- ;;
+;? --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;> --- TBD --- ;;
+;> --- TBD --- ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = false / true ;;
+;< eax = false / true ;;
;;================================================================================================;;
push edx
mov edx, [_img]
cmp [edx + Image.Data], 0
- je @f
+ je @f
invoke mem.free, [edx + Image.Data]
@@: cmp [edx + Image.Extended], 0
- je @f
+ je @f
invoke mem.free, [edx + Image.Extended]
- @@: invoke mem.free, edx
+ @@: invoke mem.free, edx
pop edx
ret
endp
@@ -2580,21 +2580,21 @@ proc img.resize_data _img, _width, _height ;////////////////////////////////////
jnz .error
imul eax, [_width]
test eax, eax
- jz .error
+ jz .error
cmp [ebx + Image.Type], Image.bpp1
- jz .bpp1
+ jz .bpp1
cmp [ebx + Image.Type], Image.bpp2i
- jz .bpp2i
+ jz .bpp2i
cmp [ebx + Image.Type], Image.bpp4i
- jz .bpp4i
+ jz .bpp4i
cmp [ebx + Image.Type], Image.bpp8i
- jz .bpp8i
+ jz .bpp8i
cmp [ebx + Image.Type], Image.bpp8g
- jz .bpp8g
+ jz .bpp8g
cmp [ebx + Image.Type], Image.bpp8a
- jz .bpp8a
+ jz .bpp8a
cmp [ebx + Image.Type], Image.bpp24
- jz .bpp24
+ jz .bpp24
.bpp32:
shl eax, 2
jmp @f
@@ -2659,8 +2659,8 @@ proc img.resize_data _img, _width, _height ;////////////////////////////////////
@@:
mov esi, eax
invoke mem.realloc, [ebx + Image.Data], eax
- or eax, eax
- jz .error
+ or eax, eax
+ jz .error
mov [ebx + Image.Data], eax
push [_width]
@@ -2701,27 +2701,27 @@ endp
;;================================================================================================;;
img._.get_scanline_len: ;/////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
-;? Get scanline length of image in bytes ;;
+;? Get scanline length of image in bytes ;;
;;------------------------------------------------------------------------------------------------;;
-;> eax = width of image in pixels ;;
-;> ebx = image ;;
+;> eax = width of image in pixels ;;
+;> ebx = image ;;
;;------------------------------------------------------------------------------------------------;;
-;< eax = scanline length in bytes ;;
+;< eax = scanline length in bytes ;;
;;================================================================================================;;
cmp [ebx + Image.Type], Image.bpp1
- jz .bpp1.1
+ jz .bpp1.1
cmp [ebx + Image.Type], Image.bpp2i
- jz .bpp2i.1
+ jz .bpp2i.1
cmp [ebx + Image.Type], Image.bpp4i
- jz .bpp4i.1
+ jz .bpp4i.1
cmp [ebx + Image.Type], Image.bpp8i
- jz .bpp8.1
+ jz .bpp8.1
cmp [ebx + Image.Type], Image.bpp8g
- jz .bpp8.1
+ jz .bpp8.1
cmp [ebx + Image.Type], Image.bpp8a
- jz .bpp8a.1
+ jz .bpp8a.1
cmp [ebx + Image.Type], Image.bpp24
- jz .bpp24.1
+ jz .bpp24.1
add eax, eax
cmp [ebx + Image.Type], Image.bpp32
jnz .quit
@@ -2752,7 +2752,7 @@ img._.get_scanline_len: ;///////////////////////////////////////////////////////
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
-;! Below is private data you should never use directly from your code ;;
+;! Below is private data you should never use directly from your code ;;
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
@@ -2761,33 +2761,33 @@ section '.data' data readable writable align 16
;include_debug_strings
align 4
-type2bpp dd 8, 24, 32, 15, 16, 1, 9, 2, 4
+type2bpp dd 8, 24, 32, 15, 16, 1, 9, 2, 4
img._.do_rgb.handlers:
- dd img._.do_rgb.bpp8i
- dd img._.do_rgb.bpp24
- dd img._.do_rgb.bpp32
- dd img._.do_rgb.bpp15.amd ; can be overwritten in lib_init
- dd img._.do_rgb.bpp16.amd ; can be overwritten in lib_init
- dd img._.do_rgb.bpp1
- dd img._.do_rgb.bpp8g
- dd img._.do_rgb.bpp2i
- dd img._.do_rgb.bpp4i
+ dd img._.do_rgb.bpp8i
+ dd img._.do_rgb.bpp24
+ dd img._.do_rgb.bpp32
+ dd img._.do_rgb.bpp15.amd ; can be overwritten in lib_init
+ dd img._.do_rgb.bpp16.amd ; can be overwritten in lib_init
+ dd img._.do_rgb.bpp1
+ dd img._.do_rgb.bpp8g
+ dd img._.do_rgb.bpp2i
+ dd img._.do_rgb.bpp4i
img.flip.layer.handlers_horz:
- dd img.flip.layer.bpp8ig_horz
- dd img.flip.layer.bpp24_horz
- dd img.flip.layer.bpp32_horz
- dd img.flip.layer.bpp1x_horz
- dd img.flip.layer.bpp1x_horz
- dd img.flip.layer.bpp1_horz
- dd img.flip.layer.bpp8ig_horz
- dd img.flip.layer.bpp2i_horz
- dd img.flip.layer.bpp4i_horz
+ dd img.flip.layer.bpp8ig_horz
+ dd img.flip.layer.bpp24_horz
+ dd img.flip.layer.bpp32_horz
+ dd img.flip.layer.bpp1x_horz
+ dd img.flip.layer.bpp1x_horz
+ dd img.flip.layer.bpp1_horz
+ dd img.flip.layer.bpp8ig_horz
+ dd img.flip.layer.bpp2i_horz
+ dd img.flip.layer.bpp4i_horz
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
-;! Exported functions section ;;
+;! Exported functions section ;;
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
@@ -2796,33 +2796,33 @@ img.flip.layer.handlers_horz:
align 4
@EXPORT:
-export \
- lib_init , 'lib_init' , \
- 0x00050007 , 'version' , \
- img.is_img , 'img_is_img' , \
- img.info , 'img_info' , \
+export \
+ lib_init , 'lib_init' , \
+ 0x00050007 , 'version' , \
+ img.is_img , 'img_is_img' , \
+ img.info , 'img_info' , \
img.from_file , 'img_from_file' , \
- img.to_file , 'img_to_file' , \
+ img.to_file , 'img_to_file' , \
img.from_rgb , 'img_from_rgb' , \
- img.to_rgb , 'img_to_rgb' , \
- img.to_rgb2 , 'img_to_rgb2' , \
- img.decode , 'img_decode' , \
- img.encode , 'img_encode' , \
- img.create , 'img_create' , \
- img.destroy , 'img_destroy' , \
+ img.to_rgb , 'img_to_rgb' , \
+ img.to_rgb2 , 'img_to_rgb2' , \
+ img.decode , 'img_decode' , \
+ img.encode , 'img_encode' , \
+ img.create , 'img_create' , \
+ img.destroy , 'img_destroy' , \
img.destroy.layer , 'img_destroy_layer' , \
- img.count , 'img_count' , \
+ img.count , 'img_count' , \
img.lock_bits , 'img_lock_bits' , \
img.unlock_bits , 'img_unlock_bits' , \
- img.flip , 'img_flip' , \
+ img.flip , 'img_flip' , \
img.flip.layer , 'img_flip_layer' , \
- img.rotate , 'img_rotate' , \
+ img.rotate , 'img_rotate' , \
img.rotate.layer , 'img_rotate_layer' , \
- img.draw , 'img_draw' , \
- img.scale , 'img_scale' , \
+ img.draw , 'img_draw' , \
+ img.scale , 'img_scale' , \
img.get_scaled_size, 'img_get_scaled_size', \
- img.convert , 'img_convert' , \
- img.blend , 'img_blend' , \
+ img.convert , 'img_convert' , \
+ img.blend , 'img_blend' , \
img.resize_data , 'img_resize_data' , \
img.formats_table , 'img_formats_table'
@@ -2831,32 +2831,32 @@ export \
align 16
@IMPORT:
-library \
- archiver, 'archiver.obj', \
- libio , 'libio.obj'
+library \
+ archiver, 'archiver.obj', \
+ libio , 'libio.obj'
-import archiver, \
- deflate_unpack2, 'deflate_unpack2',\
- deflateInit2, 'deflateInit2',\
- deflateReset, 'deflateReset',\
- deflate, 'deflate',\
- deflateEnd, 'deflateEnd',\
- calc_crc32, 'calc_crc32'
+import archiver, \
+ deflate_unpack2, 'deflate_unpack2',\
+ deflateInit2, 'deflateInit2',\
+ deflateReset, 'deflateReset',\
+ deflate, 'deflate',\
+ deflateEnd, 'deflateEnd',\
+ calc_crc32, 'calc_crc32'
-import libio , \
- file.size , 'file_size' , \
- file.open , 'file_open' , \
- file.read , 'file_read' , \
- file.close, 'file_close'
+import libio , \
+ file.size , 'file_size' , \
+ file.open , 'file_open' , \
+ file.read , 'file_read' , \
+ file.close, 'file_close'
align 4
; mutex for unpacker loading
-deflate_loader_mutex dd 0
+deflate_loader_mutex dd 0
; default palette for GIF - b&w
gif_default_palette:
- db 0, 0, 0
- db 0xFF, 0xFF, 0xFF
+ db 0, 0, 0
+ db 0xFF, 0xFF, 0xFF
; uninitialized data - global constant tables
mem.alloc dd ?
@@ -2865,7 +2865,7 @@ mem.realloc dd ?
dll.load dd ?
; data for YCbCr -> RGB translation
-color_table_1 rd 256
-color_table_2 rd 256
-color_table_3 rd 256
-color_table_4 rd 256
+color_table_1 rd 256
+color_table_2 rd 256
+color_table_3 rd 256
+color_table_4 rd 256
diff --git a/programs/develop/libraries/libs-dev/libimg/png/libpng/png.inc b/programs/develop/libraries/libs-dev/libimg/png/libpng/png.inc
index d93a75a01d..01b75279b0 100644
--- a/programs/develop/libraries/libs-dev/libimg/png/libpng/png.inc
+++ b/programs/develop/libraries/libs-dev/libimg/png/libpng/png.inc
@@ -1465,34 +1465,34 @@ PNG_FORMAT_FLAG_AFIRST equ 0x20 ;alpha channel comes first
PNG_FORMAT_GRAY equ 0
PNG_FORMAT_GA equ PNG_FORMAT_FLAG_ALPHA
-PNG_FORMAT_AG equ (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST)
+PNG_FORMAT_AG equ (PNG_FORMAT_GA or PNG_FORMAT_FLAG_AFIRST)
PNG_FORMAT_RGB equ PNG_FORMAT_FLAG_COLOR
-PNG_FORMAT_BGR equ (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR)
-PNG_FORMAT_RGBA equ (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA)
-PNG_FORMAT_ARGB equ (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST)
-PNG_FORMAT_BGRA equ (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA)
-PNG_FORMAT_ABGR equ (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST)
+PNG_FORMAT_BGR equ (PNG_FORMAT_FLAG_COLOR or PNG_FORMAT_FLAG_BGR)
+PNG_FORMAT_RGBA equ (PNG_FORMAT_RGB or PNG_FORMAT_FLAG_ALPHA)
+PNG_FORMAT_ARGB equ (PNG_FORMAT_RGBA or PNG_FORMAT_FLAG_AFIRST)
+PNG_FORMAT_BGRA equ (PNG_FORMAT_BGR or PNG_FORMAT_FLAG_ALPHA)
+PNG_FORMAT_ABGR equ (PNG_FORMAT_BGRA or PNG_FORMAT_FLAG_AFIRST)
; Then the linear 2-byte formats. When naming these "Y" is used to
; indicate a luminance (gray) channel.
PNG_FORMAT_LINEAR_Y equ PNG_FORMAT_FLAG_LINEAR
-PNG_FORMAT_LINEAR_Y_ALPHA equ (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA)
-PNG_FORMAT_LINEAR_RGB equ (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR)
+PNG_FORMAT_LINEAR_Y_ALPHA equ (PNG_FORMAT_FLAG_LINEAR or PNG_FORMAT_FLAG_ALPHA)
+PNG_FORMAT_LINEAR_RGB equ (PNG_FORMAT_FLAG_LINEAR or PNG_FORMAT_FLAG_COLOR)
PNG_FORMAT_LINEAR_RGB_ALPHA equ\
- (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA)
+ (PNG_FORMAT_FLAG_LINEAR or PNG_FORMAT_FLAG_COLOR or PNG_FORMAT_FLAG_ALPHA)
; With color-mapped formats the image data is one byte for each pixel, the byte
; is an index into the color-map which is formatted as above. To obtain a
; color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP
; to one of the above definitions, or you can use one of the definitions below.
-PNG_FORMAT_RGB_COLORMAP equ (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP)
-PNG_FORMAT_BGR_COLORMAP equ (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP)
-PNG_FORMAT_RGBA_COLORMAP equ (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP)
-PNG_FORMAT_ARGB_COLORMAP equ (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP)
-PNG_FORMAT_BGRA_COLORMAP equ (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP)
-PNG_FORMAT_ABGR_COLORMAP equ (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP)
+PNG_FORMAT_RGB_COLORMAP equ (PNG_FORMAT_RGB or PNG_FORMAT_FLAG_COLORMAP)
+PNG_FORMAT_BGR_COLORMAP equ (PNG_FORMAT_BGR or PNG_FORMAT_FLAG_COLORMAP)
+PNG_FORMAT_RGBA_COLORMAP equ (PNG_FORMAT_RGBA or PNG_FORMAT_FLAG_COLORMAP)
+PNG_FORMAT_ARGB_COLORMAP equ (PNG_FORMAT_ARGB or PNG_FORMAT_FLAG_COLORMAP)
+PNG_FORMAT_BGRA_COLORMAP equ (PNG_FORMAT_BGRA or PNG_FORMAT_FLAG_COLORMAP)
+PNG_FORMAT_ABGR_COLORMAP equ (PNG_FORMAT_ABGR or PNG_FORMAT_FLAG_COLORMAP)
; PNG_IMAGE macros
@@ -1555,8 +1555,8 @@ local .end0
local .end1
mov eax,fmt
and eax,PNG_FORMAT_FLAG_COLORMAP
- cmp eax,0
- je .end0
+ or eax,eax
+ jz .end0
xor eax,eax
inc eax
jmp .end1
@@ -1573,9 +1573,11 @@ macro PNG_IMAGE_PIXEL_CHANNELS fmt
; color-mapped image.
-;#define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\
-; PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt)
-; /* The size, in bytes, of each component in a pixel; 1 for a color-mapped
+macro PNG_IMAGE_PIXEL_COMPONENT_SIZE fmt
+{
+ PNG_IMAGE_PIXEL_ PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt
+}
+; The size, in bytes, of each component in a pixel; 1 for a color-mapped
; image.
diff --git a/programs/develop/libraries/libs-dev/libimg/png/libpng/pngset.asm b/programs/develop/libraries/libs-dev/libimg/png/libpng/pngset.asm
index 6182a64820..c09ff6d18d 100644
--- a/programs/develop/libraries/libs-dev/libimg/png/libpng/pngset.asm
+++ b/programs/develop/libraries/libs-dev/libimg/png/libpng/pngset.asm
@@ -24,11 +24,11 @@ proc png_set_bKGD uses ecx edi esi, png_ptr:dword, info_ptr:dword, background:dw
cmp dword[png_ptr],0
je .end_f
mov edi,[info_ptr]
- cmp edi,0
- je .end_f
+ or edi,edi
+ jz .end_f
mov esi,[background]
- cmp esi,0
- je .end_f ;if (..==0 || ..==0 || ..==0) return
+ or esi,esi
+ jz .end_f ;if (..==0 || ..==0 || ..==0) return
or dword[edi+png_info_def.valid],PNG_INFO_bKGD
add edi,png_info_def.background
@@ -87,11 +87,11 @@ proc png_set_cHRM_XYZ_fixed uses edi esi, png_ptr:dword, info_ptr:dword,\
png_debug1 1, 'in %s storage function', 'cHRM XYZ fixed'
mov edi,[png_ptr]
- cmp edi,0
- je .end_f
+ or edi,edi
+ jz .end_f
mov esi,[info_ptr]
- cmp esi,0
- je .end_f ;if (..==0 || ..==0) return
+ or esi,esi
+ jz .end_f ;if (..==0 || ..==0) return
; XYZ.red_X = int_red_X;
; XYZ.red_Y = int_red_Y;
@@ -155,11 +155,11 @@ proc png_set_gAMA_fixed uses eax edi esi, png_ptr:dword, info_ptr:dword, file_ga
png_debug1 1, 'in %s storage function', 'gAMA'
mov edi,[png_ptr]
- cmp edi,0
- je .end_f
+ or edi,edi
+ jz .end_f
mov esi,[info_ptr]
- cmp esi,0
- je .end_f ;if (..== 0 || ..== 0) return
+ or esi,esi
+ jz .end_f ;if (..== 0 || ..== 0) return
mov eax,esi
add eax,png_info_def.colorspace
@@ -186,11 +186,11 @@ proc png_set_hIST uses edi esi, png_ptr:dword, info_ptr:dword, hist:dword
png_debug1 1, 'in %s storage function', 'hIST'
mov edi,[png_ptr]
- cmp edi,0
- je .end_f
+ or edi,edi
+ jz .end_f
mov esi,[info_ptr]
- cmp esi,0
- je .end_f ;if (..== 0 || ..== 0) return
+ or esi,esi
+ jz .end_f ;if (..== 0 || ..== 0) return
; if (info_ptr->num_palette == 0 || info_ptr->num_palette
; > PNG_MAX_PALETTE_LENGTH)
@@ -236,11 +236,11 @@ proc png_set_IHDR, png_ptr:dword, info_ptr:dword,\
png_debug1 1, 'in %s storage function', 'IHDR'
pushad
mov edi,[png_ptr]
- cmp edi,0
- je .end_f
+ or edi,edi
+ jz .end_f
mov esi,[info_ptr]
- cmp esi,0
- je .end_f ;if (..== 0 || ..== 0) return
+ or esi,esi
+ jz .end_f ;if (..== 0 || ..== 0) return
mov eax,[width]
mov [esi+png_info_def.width],eax
@@ -271,8 +271,8 @@ pushad
@@:
mov eax,ebx
and eax,PNG_COLOR_MASK_COLOR
- cmp eax,0
- je @f ;else if (..!=0)
+ or eax,eax
+ jz @f ;else if (..!=0)
mov byte[esi+png_info_def.channels], 3
jmp .end0
@@: ;else
@@ -281,8 +281,8 @@ pushad
mov eax,ebx
and eax,PNG_COLOR_MASK_ALPHA
- cmp eax,0
- je @f ;else if (..!=0)
+ or eax,eax
+ jz @f ;else if (..!=0)
inc byte[esi+png_info_def.channels]
@@:
@@ -307,8 +307,8 @@ proc png_set_oFFs uses eax esi, png_ptr:dword, info_ptr:dword, offset_x:dword, o
cmp dword[png_ptr],0
je @f
mov esi,[info_ptr]
- cmp esi,0
- je @f ;if (..==0 || ..==0) return
+ or esi,esi
+ jz @f ;if (..==0 || ..==0) return
mov eax,[offset_x]
mov [esi+png_info_def.x_offset],eax
@@ -332,11 +332,11 @@ proc png_set_pCAL uses edi esi, png_ptr:dword, info_ptr:dword, purpose:dword, X0
png_debug1 1, 'in %s storage function', 'pCAL'
mov edi,[png_ptr]
- cmp edi,0
- je .end_f
+ or edi,edi
+ jz .end_f
mov esi,[info_ptr]
- cmp esi,0
- je .end_f
+ or esi,esi
+ jz .end_f
cmp dword[purpose],0
je .end_f
cmp dword[units],0
@@ -599,11 +599,11 @@ proc png_set_PLTE uses eax edi esi, png_ptr:dword, info_ptr:dword, palette:dword
png_debug1 1, 'in %s storage function', 'PLTE'
mov edi,[png_ptr]
- cmp edi,0
- je .end_f
+ or edi,edi
+ jz .end_f
mov esi,[info_ptr]
- cmp esi,0
- je .end_f ;if (..==0 || ..==0) return
+ or esi,esi
+ jz .end_f ;if (..==0 || ..==0) return
; max_palette_length = (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ?
; (1 << info_ptr->bit_depth) : PNG_MAX_PALETTE_LENGTH;
@@ -679,11 +679,11 @@ proc png_set_sRGB uses eax edi esi, png_ptr:dword, info_ptr:dword, srgb_intent:d
png_debug1 1, 'in %s storage function', 'sRGB'
mov edi,[png_ptr]
- cmp edi,0
- je .end_f
+ or edi,edi
+ jz .end_f
mov esi,[info_ptr]
- cmp esi,0
- je .end_f ;if (..==0 || ..==0)
+ or esi,esi
+ jz .end_f ;if (..==0 || ..==0)
mov eax,esi
add eax,png_info_def.colorspace
@@ -790,8 +790,8 @@ proc png_set_text uses eax edi, png_ptr:dword, info_ptr:dword, text_ptr:dword, n
mov edi,[png_ptr]
stdcall png_set_text_2, edi, [info_ptr], [text_ptr], [num_text]
- cmp eax,0
- je @f ;if (..!=0)
+ or eax,eax
+ jz @f ;if (..!=0)
png_error edi, 'Insufficient memory to store text'
@@:
ret
@@ -997,18 +997,18 @@ proc png_set_tIME uses eax ebx ecx edi esi, png_ptr:dword, info_ptr:dword, mod_t
png_debug1 1, 'in %s storage function', 'tIME'
mov ebx,[png_ptr]
- cmp ebx,0
- je .end_f
+ or ebx,ebx
+ jz .end_f
mov edi,[info_ptr]
- cmp edi,0
- je .end_f
+ or edi,edi
+ jz .end_f
mov esi,[mod_time]
- cmp esi,0
- je .end_f
+ or esi,esi
+ jz .end_f
mov eax,[ebx+png_struct.mode]
and eax,PNG_WROTE_tIME
- cmp eax,0
- jne .end_f ;if (..==0 || ..==0 || ..==0 || ..!=0) return
+ or eax,eax
+ jnz .end_f ;if (..==0 || ..==0 || ..==0 || ..!=0) return
cmp byte[esi+png_time.month],0
je @f
@@ -1251,11 +1251,11 @@ proc png_set_unknown_chunks uses edi esi, png_ptr:dword, info_ptr:dword, unknown
; png_unknown_chunkp np;
mov edi,[png_ptr]
- cmp edi,0
- je .end_f
+ or edi,edi
+ jz .end_f
mov esi,[info_ptr]
- cmp esi,0
- je .end_f
+ or esi,esi
+ jz .end_f
cmp dword[num_unknowns],0
jle .end_f
cmp dword[unknowns],0
@@ -1431,8 +1431,8 @@ proc png_set_keep_unknown_chunks uses edi, png_ptr:dword, keep:dword, chunk_list
; uint num_chunks, old_num_chunks;
mov edi,[png_ptr]
- cmp edi,0
- je .end_f ;if (..== 0) return
+ or edi,edi
+ jz .end_f ;if (..== 0) return
; if (keep < 0 || keep >= PNG_HANDLE_CHUNK_LAST)
; {
@@ -1588,8 +1588,8 @@ proc png_set_read_user_chunk_fn uses eax edi, png_ptr:dword, user_chunk_ptr:dwor
png_debug 1, 'in png_set_read_user_chunk_fn'
mov edi,[png_ptr]
- cmp edi,0
- je .end_f
+ or edi,edi
+ jz .end_f
mov eax,[read_user_chunk_fn]
mov [edi+png_struct.read_user_chunk_fn],eax
@@ -1605,11 +1605,11 @@ proc png_set_rows uses eax edi esi, png_ptr:dword, info_ptr:dword, row_pointers:
png_debug1 1, 'in %s storage function', 'rows'
mov edi,[png_ptr]
- cmp edi,0
- je .end_f
+ or edi,edi
+ jz .end_f
mov esi,[info_ptr]
- cmp esi,0
- je .end_f ;if (..==0 || ..==0) return
+ or esi,esi
+ jz .end_f ;if (..==0 || ..==0) return
mov eax,[row_pointers]
cmp dword[esi+png_info_def.row_pointers],0
@@ -1620,8 +1620,8 @@ proc png_set_rows uses eax edi esi, png_ptr:dword, info_ptr:dword, row_pointers:
@@:
mov [esi+png_info_def.row_pointers],eax
- cmp eax,0
- je .end_f ;if (..!=0)
+ or eax,eax
+ jz .end_f ;if (..!=0)
or dword[esi+png_info_def.valid],PNG_INFO_IDAT
.end_f:
ret
@@ -1631,8 +1631,8 @@ endp
align 4
proc png_set_compression_buffer_size uses edi, png_ptr:dword, size:dword
mov edi,[png_ptr]
- cmp edi,0
- je .end_f ;if (..==0) return
+ or edi,edi
+ jz .end_f ;if (..==0) return
; if (size == 0 || size > PNG_UINT_31_MAX)
; png_error(png_ptr, "invalid compression buffer size");
@@ -1707,8 +1707,8 @@ proc png_set_user_limits uses eax edi, png_ptr:dword, user_width_max:dword, user
; regardless of dimensions, set both limits to 0x7fffffff.
mov edi,[png_ptr]
- cmp edi,0
- je @f
+ or edi,edi
+ jz @f
mov eax,[user_width_max]
mov [edi+png_struct.user_width_max],eax
mov eax,[user_height_max]
diff --git a/programs/develop/libraries/libs-dev/libimg/png/libpng/pngwrite.asm b/programs/develop/libraries/libs-dev/libimg/png/libpng/pngwrite.asm
index 016fab235b..6141bc54cd 100644
--- a/programs/develop/libraries/libs-dev/libimg/png/libpng/pngwrite.asm
+++ b/programs/develop/libraries/libs-dev/libimg/png/libpng/pngwrite.asm
@@ -99,11 +99,11 @@ proc png_write_info_before_PLTE, png_ptr:dword, info_ptr:dword
pushad
mov edi,[png_ptr]
- cmp edi,0
- je .end_f
+ or edi,edi
+ jz .end_f
mov esi,[info_ptr]
- cmp esi,0
- je .end_f ;if(..==0 || ..==0) return
+ or esi,esi
+ jz .end_f ;if(..==0 || ..==0) return
mov eax,[edi+png_struct.mode]
and eax,PNG_WROTE_INFO_BEFORE_PLTE
@@ -256,11 +256,11 @@ pushad
png_debug 1, 'in png_write_info'
mov edi,[png_ptr]
- cmp edi,0
- je .end_f
+ or edi,edi
+ jz .end_f
mov esi,[info_ptr]
- cmp esi,0
- je .end_f ;if (..==0 || ..==0) return
+ or esi,esi
+ jz .end_f ;if (..==0 || ..==0) return
stdcall png_write_info_before_PLTE, edi, esi
@@ -1842,7 +1842,6 @@ proc png_image_write_init uses ebx ecx edx edi esi, image:dword
test eax,eax
jz .end0 ;if (..!=0)
mov edi,eax
- or dword[eax+png_struct.transformations],PNG_BGR ;transformation rgb for KoliriOS
stdcall png_create_info_struct, edi
;eax = info_ptr
@@ -2454,16 +2453,18 @@ endl
; The following four ints are actually booleans
and ecx,PNG_FORMAT_FLAG_COLORMAP
- mov [colormap],ecx
+ mov [colormap],ecx ;colormap = (format & PNG_FORMAT_FLAG_COLORMAP)
not ecx
+
mov eax,[format]
and eax,PNG_FORMAT_FLAG_LINEAR
- mov [linear],eax
- mov eax,[format]
and eax,ecx
+ mov [linear],eax ;linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR)
+
+ mov eax,[format]
and eax,PNG_FORMAT_FLAG_ALPHA
and eax,ecx
- mov [alpha],eax
+ mov [alpha],eax ;alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA)
xor eax,eax ;false
cmp dword[edx+png_image_write_control.convert_to_8bit],0
jne @f
@@ -2758,7 +2759,7 @@ end if
; supported by the rest of the libpng write code; call it directly.
.end9: ;else
-if 1 ;;; IDAT compress all (only 24 bit)
+if 1 ;;; IDAT compress all
cmp dword[ebx+png_image.height],1
jl .end8
mov ecx,[edx+png_image_write_control.row_bytes]
@@ -2794,7 +2795,7 @@ locals
endl
pushad
mov edi,[png_ptr]
-png_debug 1, 'IDAT compress all'
+png_debug1 2, 'IDAT compress all len = %d', [len]
;create buffer with filters
stdcall png_zalloc, edi, 1, [len]
@@ -2815,9 +2816,14 @@ png_debug 1, 'IDAT compress all'
;init buffer with filters
mov ebx,[width]
mov edx,[height]
+ movzx eax,byte[edi+png_struct.color_type]
mov edi,[buf_f]
mov esi,[buf]
- .cycle0:
+
+ cmp eax,PNG_COLOR_TYPE_RGB_ALPHA
+ je .cycle5
+
+ .cycle0: ;24 bit image
cmp edx,1
jl .cycle0end
mov ecx,ebx
@@ -2835,14 +2841,30 @@ align 4
dec edx
jmp .cycle0
.cycle0end:
+ jmp .cycle5end
+
+ .cycle5: ;32 bit image
+ cmp edx,1
+ jl .cycle5end
+ mov ecx,ebx
+ xor al,al
+ stosb ;insert filter (0 - none)
+align 4
+ .cycle6:
+ lodsd
+ bswap eax
+ ror eax,8
+ stosd
+ loop .cycle6
+ dec edx
+ jmp .cycle5
+ .cycle5end:
;make filters
mov edx,[height]
- mov esi,[width]
- imul esi,3 ;esi - rowbytes
-
- inc esi
mov edi,[png_ptr]
+ mov esi,[edi+png_struct.rowbytes]
+ inc esi
cmp dword[edi+png_struct.try_row],0
jne @f ;if (..==0)
stdcall png_malloc, edi, esi
@@ -2938,8 +2960,7 @@ align 4
.cycle3end:
mov edi,[png_ptr]
- mov esi,edi
- add esi,png_struct.zstream
+ lea esi,[edi+png_struct.zstream]
stdcall [deflateInit2], esi,\
-1, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY
@@ -3095,8 +3116,8 @@ endl
; Write the image to the given buffer, or count the bytes if it is NULL
mov ebx,[image]
- cmp ebx,0
- je .end0
+ or ebx,ebx
+ jz .end0
cmp dword[ebx+png_image.version],PNG_IMAGE_VERSION
jne .end0 ;if (..!=0 && ..==..)
cmp dword[memory_bytes],0
@@ -3142,8 +3163,8 @@ endl
stdcall png_image_free, ebx
; write_memory returns true even if we ran out of buffer.
- cmp ecx,0 ;if (..)
- je .end4
+ or ecx,ecx ;if (..)
+ jz .end4
; On out-of-buffer this function returns '0' but still updates
; memory_bytes:
@@ -3167,8 +3188,8 @@ endl
std_png_image_error ebx, 'png_image_write_to_memory: invalid argument'
jmp .end_f
.end0:
- cmp ebx,0
- je .end1 ;else if (..!=0)
+ or ebx,ebx
+ jz .end1 ;else if (..!=0)
std_png_image_error ebx, 'png_image_write_to_memory: incorrect PNG_IMAGE_VERSION'
jmp .end_f
.end1: ;else
diff --git a/programs/develop/libraries/libs-dev/libimg/png/libpng/pngwutil.asm b/programs/develop/libraries/libs-dev/libimg/png/libpng/pngwutil.asm
index 63b62b713b..5e1b47fb90 100644
--- a/programs/develop/libraries/libs-dev/libimg/png/libpng/pngwutil.asm
+++ b/programs/develop/libraries/libs-dev/libimg/png/libpng/pngwutil.asm
@@ -362,8 +362,7 @@ endl
cmp dword[edi+png_struct.zowner],0
je .end0 ;if (..!=0)
- mov ebx,ebp
- sub ebx,64
+ lea ebx,[ebp-64]
if (PNG_WARNINGS_SUPPORTED eq 1) | (PNG_ERROR_TEXT_SUPPORTED eq 1)
mov eax,[owner]
mov [ebx],eax
@@ -1012,8 +1011,7 @@ end if
mov [edi+png_struct.usr_channels],al
; Pack the header information into the buffer
- mov ebx,ebp
- sub ebx,13
+ lea ebx,[ebp-13]
stdcall png_save_uint_32, ebx, [width]
add ebx,4
stdcall png_save_uint_32, ebx, [height]
@@ -1043,8 +1041,7 @@ end if
cmp byte[edi+png_struct.color_type],PNG_COLOR_TYPE_PALETTE
je @f
cmp byte[edi+png_struct.bit_depth],8
- jl @f ;if ((..==..)||(..<..))
- jmp .els_5
+ jge .els_5 ;if ((..==..)||(..<..))
@@:
mov byte[edi+png_struct.do_filter], PNG_FILTER_NONE
jmp .end_5
@@ -1371,8 +1368,7 @@ endl
png_debug 1, 'in png_write_gAMA'
; file_gamma is saved in 1/100,000ths
- mov ebx,ebp
- sub ebx,4
+ lea ebx,[ebp-4]
stdcall png_save_uint_32 ,ebx, [file_gamma]
stdcall png_write_complete_chunk, [png_ptr], png_gAMA, ebx, 4
ret
@@ -1441,8 +1437,7 @@ endl
; png_error(png_ptr, "Profile length does not match profile");
; }
- mov ebx,ebp
- sub ebx,sizeof.compression_state
+ lea ebx,[ebp-sizeof.compression_state]
mov ecx,ebx ;ecx = &comp
sub ebx,81 ;ebx = &new_name
stdcall png_check_keyword, edi, [name], ebx
@@ -1632,8 +1627,7 @@ endl
; Each value is saved in 1/100,000ths
mov eax,[xy]
- mov ebx,ebp
- sub ebx,32
+ lea ebx,[ebp-32]
; png_save_int_32(buf, xy->whitex);
; png_save_int_32(buf + 4, xy->whitey);
@@ -1691,8 +1685,7 @@ endl
jmp .end_f
@@:
movzx eax,word[ecx+png_color_16.gray]
- mov ebx,ebp
- sub ebx,6
+ lea ebx,[ebp-6]
stdcall png_save_uint_16, ebx, eax
stdcall png_write_complete_chunk, edi, png_tRNS, ebx, 2
jmp .end_f
@@ -1701,8 +1694,7 @@ endl
cmp dword[color_type],PNG_COLOR_TYPE_RGB
jne .end3 ;else if (..== ..)
; Three 16-bit values
- mov ebx,ebp
- sub ebx,6
+ lea ebx,[ebp-6]
mov ecx,[tran]
movzx eax,word[ecx+png_color_16.red]
stdcall png_save_uint_16, ebx, eax
@@ -1720,8 +1712,8 @@ end if
mov al,[ebx]
or al,[ebx+2]
or al,[ebx+4]
- cmp al,0
- je @f ;if (..|..|..!=0)
+ or al,al
+ jz @f ;if (..|..|..!=0)
png_app_warning edi, 'Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8'
jmp .end_f
@@:
@@ -1947,8 +1939,7 @@ endl
png_debug 1, 'in png_write_iTXt'
pushad
mov edi,[png_ptr]
- mov ebx,ebp
- sub ebx,82+sizeof.compression_state
+ lea ebx,[ebp-(82+sizeof.compression_state)]
stdcall png_check_keyword, edi, [key], ebx
mov [key_len],eax
@@ -2057,8 +2048,7 @@ endl
png_warning edi, 'Unrecognized unit type for oFFs chunk'
@@:
- mov ebx,ebp
- sub ebx,9
+ lea ebx,[ebp-9]
stdcall png_save_int_32, ebx, [x_offset]
add ebx,4
stdcall png_save_int_32, ebx, [y_offset]
@@ -2095,8 +2085,7 @@ pushad
png_error edi, 'Unrecognized equation type for pCAL chunk'
@@:
- mov ebx,ebp
- sub ebx,84 ;ebx = &new_purpose
+ lea ebx,[ebp-84] ;ebx = &new_purpose
stdcall png_check_keyword, edi, [purpose], ebx
mov [purpose_len],eax
@@ -2129,8 +2118,7 @@ pushad
png_debug1 3, 'pCAL total length = %d', [total_len]
stdcall png_write_chunk_header, edi, png_pCAL, [total_len]
stdcall png_write_chunk_data, edi, ebx, [purpose_len]
- mov ebx,ebp
- sub ebx,94 ;ebx = &buf
+ lea ebx,[ebp-94] ;ebx = &buf
stdcall png_save_int_32, ebx, [X0]
add ebx,4
stdcall png_save_int_32, ebx, [X1]
@@ -2181,8 +2169,7 @@ endl
jmp .end_f
@@:
- mov ebx,ebp
- sub ebx,64
+ lea ebx,[ebp-64]
mov eax,[unit]
mov byte[ebx],al
mov ecx,[wlen]
@@ -2216,8 +2203,7 @@ endl
png_warning [png_ptr], 'Unrecognized unit type for pHYs chunk'
@@:
- mov ebx,ebp
- sub ebx,9
+ lea ebx,[ebp-9]
stdcall png_save_uint_32, ebx, [x_pixels_per_unit]
add ebx,4
stdcall png_save_uint_32, ebx, [y_pixels_per_unit]
@@ -2264,8 +2250,7 @@ endl
movzx ebx,word[eax+png_time.year]
push ebx
- mov ebx,ebp
- sub ebx,7
+ lea ebx,[ebp-7]
stdcall png_save_uint_16, ebx ;, year
add ebx,2
mov byte[ebx],cl ;month
diff --git a/programs/develop/libraries/libs-dev/libimg/png/png.asm b/programs/develop/libraries/libs-dev/libimg/png/png.asm
index dce91bde72..55607c0cc1 100644
--- a/programs/develop/libraries/libs-dev/libimg/png/png.asm
+++ b/programs/develop/libraries/libs-dev/libimg/png/png.asm
@@ -1178,21 +1178,29 @@ endl
mov eax,[ebx+Image.Type]
cmp eax,Image.bpp24
je @f
+ cmp eax,Image.bpp32
+ jne .error
mov ecx,LIBIMG_ERROR_BIT_DEPTH
- jmp .error
@@:
- mov edx,ebp
- sub edx,sizeof.png_image
+ lea edx,[ebp-sizeof.png_image]
mov dword[edx+png_image.version],PNG_IMAGE_VERSION
mov ecx,[ebx+Image.Width]
mov [edx+png_image.width],ecx ;Image width in pixels (columns)
+ cmp eax,Image.bpp24
+ jne @f
+ mov dword[edx+png_image.format],PNG_FORMAT_RGB
+ imul ecx,3
+ @@:
+ cmp eax,Image.bpp32
+ jne @f
+ mov dword[edx+png_image.format],PNG_FORMAT_RGBA
+ shl ecx,2
+ @@:
mov eax,[ebx+Image.Height]
mov [edx+png_image.height],eax ;Image height in pixels (rows)
- mov dword[edx+png_image.format],PNG_COLOR_TYPE_RGB
;mov dword[edx+png_image.flags],PNG_IMAGE_FLAG_???
- imul ecx,3
mov edi,ecx
imul edi,[ebx+Image.Height]
cmp edi,4096
@@ -1207,8 +1215,7 @@ endl
jmp .error
@@:
mov [encoded_file],eax
- mov edi,edx
- sub edi,4
+ lea edi,[edx-4]
stdcall png_image_write_to_memory, edx,eax,edi,0,[ebx+Image.Data],ecx,0
mov eax,[encoded_file]
mov ecx,[encoded_file_size]