Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 8462 → Rev 8463

/programs/develop/libraries/libs-dev/.test/006/test006.asm
8,7 → 8,7
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
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
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
I_END:
rd 4096
STACKTOP:
cur_dir_path:
rb 4096
library_path:
rb 4096
cur_dir_path rb 4096
library_path rb 4096
MEM:
/programs/develop/libraries/libs-dev/libimg/libimg.asm
741,7 → 741,7
endp
 
;;================================================================================================;;
proc img.encode _img, _common, _specific ;////////////////////////////////////////////////////////;;
proc img.encode uses ebx, _img, _common, _specific ;////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? encode image to some format ;;
;;------------------------------------------------------------------------------------------------;;
/programs/develop/libraries/libs-dev/libimg/png/libpng/png.inc
1465,22 → 1465,22
 
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
1487,12 → 1487,12
; 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 .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
; 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.
 
 
/programs/develop/libraries/libs-dev/libimg/png/libpng/pngset.asm
24,11 → 24,11
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
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
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
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
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
@@:
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
 
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
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
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
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
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
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
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
; 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
; 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
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
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
@@:
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
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
; 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]
/programs/develop/libraries/libs-dev/libimg/png/libpng/pngwrite.asm
99,11 → 99,11
 
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
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
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
 
; 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
and eax,ecx
mov [linear],eax ;linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR)
 
mov eax,[format]
and eax,ecx
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
; 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
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
;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
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
 
mov edi,[png_ptr]
mov esi,[edi+png_struct.rowbytes]
inc esi
mov edi,[png_ptr]
cmp dword[edi+png_struct.try_row],0
jne @f ;if (..==0)
stdcall png_malloc, edi, esi
2938,8 → 2960,7
.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
 
; 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
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
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
/programs/develop/libraries/libs-dev/libimg/png/libpng/pngwutil.asm
362,8 → 362,7
 
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
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
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
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
; 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
 
; 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
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
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
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
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
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
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
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
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
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
 
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
/programs/develop/libraries/libs-dev/libimg/png/png.asm
1178,21 → 1178,29
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
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]