* libs-dev: style of exported names changed, ini.get_int -> ini_get_int
* programs which use libs-dev updated accordingly * libimg: support for .ico and .cur files (icons and cursors) * kiv: show many different images in one file in one row git-svn-id: svn://kolibrios.org@1102 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
51a64dc292
commit
f705611d81
@ -374,41 +374,41 @@ library \
|
||||
libgfx,'libgfx.obj'
|
||||
|
||||
import libini, \
|
||||
ini.get_str,'ini.get_str',\
|
||||
ini.set_str,'ini.set_str',\
|
||||
ini.get_int,'ini.get_int',\
|
||||
ini.set_int,'ini.set_int',\
|
||||
ini.enum_sections,'ini.enum_sections',\
|
||||
ini.enum_keys,'ini.enum_keys'
|
||||
ini.get_str,'ini_get_str',\
|
||||
ini.set_str,'ini_set_str',\
|
||||
ini.get_int,'ini_get_int',\
|
||||
ini.set_int,'ini_set_int',\
|
||||
ini.enum_sections,'ini_enum_sections',\
|
||||
ini.enum_keys,'ini_enum_keys'
|
||||
|
||||
import libio, \
|
||||
\; file.aux.match_wildcard,'file.aux.match_wildcard',\
|
||||
file.find_first,'file.find_first',\
|
||||
file.find_next,'file.find_next',\
|
||||
file.find_close,'file.find_close',\
|
||||
file.open,'file.open',\
|
||||
file.seek,'file.seek',\
|
||||
file.write,'file.write',\
|
||||
file.truncate,'file.truncate',\
|
||||
file.close,'file.close'
|
||||
\; file.aux.match_wildcard,'file_aux_match_wildcard',\
|
||||
file.find_first,'file_find_first',\
|
||||
file.find_next,'file_find_next',\
|
||||
file.find_close,'file_find_close',\
|
||||
file.open,'file_open',\
|
||||
file.seek,'file_seek',\
|
||||
file.write,'file_write',\
|
||||
file.truncate,'file_truncate',\
|
||||
file.close,'file_close'
|
||||
|
||||
import libgfx, \
|
||||
gfx.open ,'gfx.open',\
|
||||
gfx.close ,'gfx.close',\
|
||||
gfx.pen.color ,'gfx.pen.color',\
|
||||
gfx.brush.color ,'gfx.brush.color',\
|
||||
gfx.pixel ,'gfx.pixel',\
|
||||
gfx.move.to ,'gfx.move.to',\
|
||||
gfx.line.to ,'gfx.line.to',\
|
||||
gfx.line ,'gfx.line',\
|
||||
gfx.polyline ,'gfx.polyline',\
|
||||
gfx.polyline.to ,'gfx.polyline.to',\
|
||||
gfx.fillrect ,'gfx.fillrect',\
|
||||
gfx.fillrect.ex ,'gfx.fillrect.ex',\
|
||||
gfx.framerect ,'gfx.framerect',\
|
||||
gfx.framerect.ex,'gfx.framerect.ex',\
|
||||
gfx.rectangle ,'gfx.rectangle',\
|
||||
gfx.rectangle.ex,'gfx.rectangle.ex'
|
||||
gfx.open ,'gfx_open',\
|
||||
gfx.close ,'gfx_close',\
|
||||
gfx.pen.color ,'gfx_pen_color',\
|
||||
gfx.brush.color ,'gfx_brush.color',\
|
||||
gfx.pixel ,'gfx_pixel',\
|
||||
gfx.move.to ,'gfx_move_to',\
|
||||
gfx.line.to ,'gfx_line_to',\
|
||||
gfx.line ,'gfx_line',\
|
||||
gfx.polyline ,'gfx_polyline',\
|
||||
gfx.polyline.to ,'gfx_polyline_to',\
|
||||
gfx.fillrect ,'gfx_fillrect',\
|
||||
gfx.fillrect.ex ,'gfx_fillrect_ex',\
|
||||
gfx.framerect ,'gfx_framerect',\
|
||||
gfx.framerect.ex,'gfx_framerect_ex',\
|
||||
gfx.rectangle ,'gfx_rectangle',\
|
||||
gfx.rectangle.ex,'gfx_rectangle_ex'
|
||||
|
||||
I_END:
|
||||
|
||||
|
@ -15,7 +15,13 @@ proc dll.Load, import_table:dword
|
||||
or eax,eax
|
||||
jz .fail
|
||||
stdcall dll.Link,eax,edx
|
||||
push eax
|
||||
mov eax, [eax]
|
||||
cmp dword [eax], 'lib_'
|
||||
pop eax
|
||||
jnz @f
|
||||
stdcall dll.Init,[eax+4]
|
||||
@@:
|
||||
pop esi
|
||||
add esi,8
|
||||
jmp .next_lib
|
||||
|
@ -423,20 +423,20 @@ align 16
|
||||
|
||||
export \
|
||||
lib_init , 'lib_init' , \
|
||||
0x01000000 , 'version' , \
|
||||
gfx.open , 'gfx.open' , \
|
||||
gfx.close , 'gfx.close' , \
|
||||
gfx.pen.color , 'gfx.pen.color' , \
|
||||
gfx.brush.color , 'gfx.brush.color' , \
|
||||
gfx.pixel , 'gfx.pixel' , \
|
||||
gfx.move.to , 'gfx.move.to' , \
|
||||
gfx.line.to , 'gfx.line.to' , \
|
||||
gfx.line , 'gfx.line' , \
|
||||
gfx.polyline , 'gfx.polyline' , \
|
||||
gfx.polyline.to , 'gfx.polyline.to' , \
|
||||
gfx.fillrect , 'gfx.fillrect' , \
|
||||
gfx.fillrect.ex , 'gfx.fillrect.ex' , \
|
||||
gfx.framerect , 'gfx.framerect' , \
|
||||
gfx.framerect.ex , 'gfx.framerect.ex' , \
|
||||
gfx.rectangle , 'gfx.rectangle' , \
|
||||
gfx.rectangle.ex , 'gfx.rectangle.ex'
|
||||
0x00020002 , 'version' , \
|
||||
gfx.open , 'gfx_open' , \
|
||||
gfx.close , 'gfx_close' , \
|
||||
gfx.pen.color , 'gfx_pen_color' , \
|
||||
gfx.brush.color , 'gfx_brush_color' , \
|
||||
gfx.pixel , 'gfx_pixel' , \
|
||||
gfx.move.to , 'gfx_move_to' , \
|
||||
gfx.line.to , 'gfx_line_to' , \
|
||||
gfx.line , 'gfx_line' , \
|
||||
gfx.polyline , 'gfx_polyline' , \
|
||||
gfx.polyline.to , 'gfx_polyline_to' , \
|
||||
gfx.fillrect , 'gfx_fillrect' , \
|
||||
gfx.fillrect.ex , 'gfx_fillrect_ex' , \
|
||||
gfx.framerect , 'gfx_framerect' , \
|
||||
gfx.framerect.ex , 'gfx_framerect_ex' , \
|
||||
gfx.rectangle , 'gfx_rectangle' , \
|
||||
gfx.rectangle.ex , 'gfx_rectangle_ex'
|
||||
|
@ -57,7 +57,7 @@ img.is.bmp:
|
||||
;endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.decode.bmp _data, _length ;//////////////////////////////////////////////////////////////;;
|
||||
proc img.decode.bmp _data, _length, _options ;////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Decode data into image if it contains correctly formed raw data in BMP format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
@ -67,71 +67,77 @@ proc img.decode.bmp _data, _length ;////////////////////////////////////////////
|
||||
;< eax = 0 (error) or pointer to image ;;
|
||||
;;================================================================================================;;
|
||||
locals
|
||||
length_rest dd ?
|
||||
img dd ?
|
||||
bTopDown db ?
|
||||
bIsIco db ?
|
||||
endl
|
||||
img.decode.bmp.length_rest equ length_rest
|
||||
mov [bIsIco], 0
|
||||
.common: ; common place for BMP and ICO
|
||||
|
||||
push ebx esi edi
|
||||
|
||||
; img.is.bmp has been already called by img.decode
|
||||
; stdcall img.is.bmp, [_data], [_length]
|
||||
; or eax, eax
|
||||
; jz .error
|
||||
|
||||
mov ebx, [_data]
|
||||
; cmp [ebx + bmp.Header.info.Compression], bmp.BI_RGB
|
||||
; je @f
|
||||
; mov eax, [ebx + bmp.Header.file.Size]
|
||||
; cmp eax, [_length]
|
||||
; jne .error
|
||||
; @@:
|
||||
cmp [bIsIco], 0
|
||||
jnz @f
|
||||
add ebx, sizeof.bmp.FileHeader
|
||||
sub [_length], sizeof.bmp.FileHeader
|
||||
@@:
|
||||
|
||||
mov eax, [ebx + bmp.Header.info.Size]
|
||||
mov eax, [ebx + bmp.InfoHeader.Size]
|
||||
; sanity check: file length must be greater than size of headers
|
||||
add eax, sizeof.bmp.FileHeader
|
||||
cmp [_length], eax
|
||||
jbe .error
|
||||
|
||||
mov [bTopDown], 0
|
||||
|
||||
cmp eax, sizeof.bmp.FileHeader + 12
|
||||
cmp eax, 12
|
||||
jz .old1
|
||||
cmp eax, sizeof.bmp.FileHeader + 40
|
||||
cmp eax, 40
|
||||
jz .normal
|
||||
cmp eax, sizeof.bmp.FileHeader + 56
|
||||
cmp eax, 56
|
||||
jnz .error
|
||||
; convert images with <= 8 bpp to 8bpp, other - to 32 bpp
|
||||
.normal:
|
||||
m2m eax, Image.bpp8
|
||||
cmp [ebx + bmp.Header.info.BitCount], 8
|
||||
cmp byte [ebx + 14], 8 ; bit count
|
||||
jbe @f
|
||||
mov al, Image.bpp32
|
||||
@@:
|
||||
push eax
|
||||
mov eax, [ebx + bmp.Header.info.Height]
|
||||
mov eax, [ebx + 8] ;[ebx + bmp.InfoHeader.Height]
|
||||
test eax, eax
|
||||
jns @f
|
||||
inc [bTopDown]
|
||||
neg eax
|
||||
@@:
|
||||
cmp [bIsIco], 0 ; for icons Height is two times larger than image height
|
||||
jz @f
|
||||
shr eax, 1
|
||||
@@:
|
||||
pushd eax
|
||||
pushd [ebx + bmp.Header.info.Width]
|
||||
pushd [ebx + 4] ;[ebx + bmp.InfoHeader.Width]
|
||||
jmp .create
|
||||
.old1:
|
||||
m2m eax, Image.bpp8
|
||||
cmp [ebx + bmp.Header.info.OldBitCount], 8
|
||||
cmp byte [ebx + 10], 8 ; bit count
|
||||
jbe @f
|
||||
mov al, Image.bpp32
|
||||
@@:
|
||||
push eax
|
||||
movsx eax, [ebx + bmp.Header.info.OldHeight]
|
||||
movsx eax, word [ebx + 6] ;[ebx + bmp.InfoHeader.OldHeight]
|
||||
test eax, eax
|
||||
jns @f
|
||||
inc [bTopDown]
|
||||
neg eax
|
||||
@@:
|
||||
cmp [bIsIco], 0 ; for icons Height is two times larger than image height
|
||||
jz @f
|
||||
shr eax, 1
|
||||
@@:
|
||||
push eax
|
||||
movzx eax, [ebx + bmp.Header.info.OldWidth]
|
||||
movzx eax, word [ebx + 4] ;[ebx + bmp.InfoHeader.OldWidth]
|
||||
push eax
|
||||
.create:
|
||||
call img.create
|
||||
@ -151,9 +157,9 @@ endl
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
pop edi
|
||||
lea esi, [ebx + sizeof.bmp.FileHeader]
|
||||
pushd [ebx + bmp.FileHeader.OffBits]
|
||||
mov ecx, [esi + bmp.InfoHeader.Size]
|
||||
push edi
|
||||
mov esi, ebx
|
||||
mov ecx, [ebx] ;[ebx + bmp.InfoHeader.Size]
|
||||
cmp ecx, 12
|
||||
jz .old2
|
||||
rep movsb
|
||||
@ -168,10 +174,28 @@ endl
|
||||
movsd ; Planes+BitCount
|
||||
.decode:
|
||||
|
||||
pop eax
|
||||
mov esi, [_length]
|
||||
sub esi, eax
|
||||
pop edi
|
||||
cmp [bIsIco], 0
|
||||
jnz @f
|
||||
mov edi, [_length]
|
||||
add edi, sizeof.bmp.FileHeader
|
||||
mov esi, [ebx - sizeof.bmp.FileHeader + bmp.FileHeader.OffBits]
|
||||
jmp .offset_calculated
|
||||
@@:
|
||||
xor esi, esi
|
||||
mov cl, byte [edi + bmp.Image.info.BitCount]
|
||||
cmp cl, 8
|
||||
ja @f
|
||||
inc esi
|
||||
add cl, 2
|
||||
shl esi, cl
|
||||
@@:
|
||||
add esi, [edi + bmp.Image.info.Size]
|
||||
mov edi, [_length]
|
||||
.offset_calculated:
|
||||
sub edi, esi
|
||||
jbe .error.free
|
||||
add esi, [_data]
|
||||
|
||||
mov eax, [edx + Image.Extended]
|
||||
mov eax, [eax + bmp.Image.info.Compression]
|
||||
@ -181,13 +205,13 @@ endl
|
||||
jmp .decoded
|
||||
@@: cmp eax, bmp.BI_RLE8
|
||||
jne @f
|
||||
cmp [ebx + bmp.Header.info.BitCount], 8
|
||||
cmp word [ebx + 14], 8 ;bmp.InfoHeader.BitCount
|
||||
jnz .error.free
|
||||
stdcall ._.rle
|
||||
jmp .decoded
|
||||
@@: cmp eax, bmp.BI_RLE4
|
||||
jne @f
|
||||
cmp [ebx + bmp.Header.info.BitCount], 4
|
||||
cmp word [ebx + 14], 4
|
||||
jnz .error.free
|
||||
stdcall ._.rle
|
||||
jmp .decoded
|
||||
@ -218,6 +242,11 @@ endl
|
||||
stdcall img.flip, [img], FLIP_VERTICAL
|
||||
@@:
|
||||
mov eax, [img]
|
||||
mov ecx, [length_rest] ; return length for ICO code
|
||||
cmp [bIsIco], 0
|
||||
jz @f
|
||||
mov [esp + 4], esi ; return pointer to end-of-data for ICO code
|
||||
@@:
|
||||
pop edi esi ebx
|
||||
ret
|
||||
|
||||
@ -228,7 +257,7 @@ endl
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.encode.bmp _img, _p_length ;/////////////////////////////////////////////////////////////;;
|
||||
proc img.encode.bmp _img, _p_length, _options ;///////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Encode image into raw data in BMP format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
@ -263,7 +292,6 @@ proc img.decode.bmp._.rgb ;/////////////////////////////////////////////////////
|
||||
;;================================================================================================;;
|
||||
mov ecx, [edx + Image.Extended]
|
||||
mov [ecx + bmp.Image.info.AlphaMask], 0
|
||||
mov edi, [edx + Image.Data]
|
||||
|
||||
movzx eax, [ecx + bmp.Image.info.BitCount]
|
||||
cmp eax, 32
|
||||
@ -297,10 +325,10 @@ img.decode.bmp._.rgb.24bpp:
|
||||
and eax, not 3
|
||||
mov ecx, [edx + Image.Height]
|
||||
imul eax, ecx
|
||||
cmp esi, eax
|
||||
sub edi, eax
|
||||
jb img.decode.bmp._.rgb.error
|
||||
mov esi, ebx
|
||||
add esi, [ebx + bmp.Header.file.OffBits]
|
||||
mov [img.decode.bmp.length_rest], edi
|
||||
mov edi, [edx + Image.Data]
|
||||
|
||||
.next_line:
|
||||
push ecx edx
|
||||
@ -447,19 +475,20 @@ img.decode.bmp._.rgb.prepare_palette:
|
||||
and eax, not 3
|
||||
mov ecx, [edx + Image.Height]
|
||||
imul eax, ecx
|
||||
cmp esi, eax
|
||||
sub edi, eax
|
||||
jb .ret
|
||||
mov esi, [ebx + bmp.Header.info.Size]
|
||||
add esi, sizeof.bmp.FileHeader
|
||||
jc .ret
|
||||
mov eax, [ebx + bmp.Header.file.OffBits]
|
||||
sub eax, esi
|
||||
jc .ret
|
||||
push edi
|
||||
mov [img.decode.bmp.length_rest], edi
|
||||
push esi
|
||||
sub esi, ebx
|
||||
jc .ret.pop
|
||||
sub esi, [ebx + bmp.InfoHeader.Size]
|
||||
jc .ret.pop
|
||||
mov eax, esi
|
||||
mov edi, [edx + Image.Palette]
|
||||
push ecx
|
||||
mov ecx, 256
|
||||
cmp esi, sizeof.bmp.FileHeader + 12
|
||||
mov esi, [ebx + bmp.InfoHeader.Size]
|
||||
cmp esi, 12
|
||||
jz .old
|
||||
shr eax, 2
|
||||
add esi, ebx
|
||||
@ -470,18 +499,21 @@ img.decode.bmp._.rgb.prepare_palette:
|
||||
rep movsd
|
||||
jmp .common
|
||||
.old:
|
||||
add esi, ebx
|
||||
@@:
|
||||
movsd
|
||||
dec esi
|
||||
sub eax, 3
|
||||
jbe @f
|
||||
sub ecx, 1
|
||||
jnz .old
|
||||
jnz @b
|
||||
@@:
|
||||
.common:
|
||||
pop ecx
|
||||
pop edi
|
||||
mov esi, ebx
|
||||
add esi, [ebx + bmp.Header.file.OffBits]
|
||||
mov edi, [edx + Image.Data]
|
||||
clc
|
||||
.ret.pop:
|
||||
pop esi
|
||||
.ret:
|
||||
ret
|
||||
endp
|
||||
@ -507,15 +539,18 @@ endl
|
||||
|
||||
mov [abs_mode_addr], .absolute_mode.rle8
|
||||
mov [enc_mode_addr], .encoded_mode.rle8
|
||||
cmp [ebx + bmp.Header.info.Compression], bmp.BI_RLE4
|
||||
cmp [ebx + bmp.InfoHeader.Compression], bmp.BI_RLE4
|
||||
jne @f
|
||||
mov [abs_mode_addr], .absolute_mode.rle4
|
||||
mov [enc_mode_addr], .encoded_mode.rle4
|
||||
@@:
|
||||
|
||||
push esi
|
||||
push edi
|
||||
xor eax, eax ; do not check file size in .prepare_palette
|
||||
push ebp
|
||||
mov ebp, [ebp] ; set parent stack frame
|
||||
call img.decode.bmp._.rgb.prepare_palette
|
||||
pop ebp
|
||||
pop ecx ; ecx = rest bytes in file
|
||||
jc .error
|
||||
|
||||
@ -712,8 +747,6 @@ locals
|
||||
delta dd ?
|
||||
endl
|
||||
|
||||
push edi
|
||||
|
||||
mov [delta], 4
|
||||
mov eax, [edx + Image.Extended]
|
||||
cmp [eax + bmp.Image.info.BitCount], 32
|
||||
@ -725,9 +758,12 @@ endl
|
||||
mov ecx, [edx + Image.Width]
|
||||
imul ecx, [edx + Image.Height]
|
||||
imul ecx, [delta]
|
||||
cmp esi, ecx
|
||||
sub edi, ecx
|
||||
jb .error
|
||||
mov ecx, [ebp] ; use parent stack frame
|
||||
mov [ecx + img.decode.bmp.length_rest - ebp], edi ; !
|
||||
|
||||
push esi
|
||||
mov esi, eax
|
||||
|
||||
mov ecx, [esi + bmp.Image.info.RedMask]
|
||||
@ -759,8 +795,7 @@ endl
|
||||
mov [unshift.Alpha], al
|
||||
|
||||
mov edi, [edx + Image.Data]
|
||||
mov esi, ebx
|
||||
add esi, [ebx + bmp.Header.file.OffBits]
|
||||
pop esi
|
||||
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
|
||||
|
@ -72,7 +72,7 @@ proc img.is.gif _data, _length ;////////////////////////////////////////////////
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.decode.gif _data, _length ;//////////////////////////////////////////////////////////////;;
|
||||
proc img.decode.gif _data, _length, _options ;////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Decode data into image if it contains correctly formed raw data in GIF format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
@ -86,6 +86,7 @@ locals
|
||||
cur_color_table_size dd ?
|
||||
transparent_color dd ?
|
||||
background_color dd ?
|
||||
options_bgr dd ?
|
||||
prev_palette dd ?
|
||||
aux_palette dd ?
|
||||
img dd ?
|
||||
@ -110,6 +111,7 @@ img.decode.gif._data equ _data
|
||||
img.decode.gif.aux_img_data equ aux_img_data
|
||||
img.decode.gif.aux_img_type equ aux_img_type
|
||||
img.decode.gif.aux_palette equ aux_palette
|
||||
img.decode.gif.options_bgr equ options_bgr
|
||||
; offset of _length parameter for child functions with ebp-based frame
|
||||
; child saved ebp, return address, 3 saved registers, 14 local variables
|
||||
img.decode.gif._length_child equ _length + 4 + 4 + 4*3 + 4*14
|
||||
@ -130,8 +132,16 @@ img.decode.gif.cur_color_table_size_child equ ebp + 4 + 4 + 4*3 + 4
|
||||
mov [prev_num_colors], eax
|
||||
lea eax, [background_color]
|
||||
mov [prev_palette], eax
|
||||
; guard against incorrect gif files, which use Restore-To-Background disposal method, but do not define bgr color
|
||||
mov dword [eax], 0xFFFFFF
|
||||
; value for bgr color in transparent images
|
||||
mov edx, 0xFFFFFF ; white bgr if no value given
|
||||
mov ecx, [_options]
|
||||
jecxz @f
|
||||
cmp [ecx + ImageDecodeOptions.UsedSize], ImageDecodeOptions.BackgroundColor + 4
|
||||
jb @f
|
||||
mov edx, [ecx + ImageDecodeOptions.BackgroundColor]
|
||||
@@:
|
||||
mov [options_bgr], edx
|
||||
mov dword [eax], edx
|
||||
; guard against incorrect gif files without any color tables
|
||||
; "If no color table is available at
|
||||
; all, the decoder is free to use a system color table or a table of its own. In
|
||||
@ -790,22 +800,11 @@ proc img.decode.gif._.superimpose ;/////////////////////////////////////////////
|
||||
jnz .has_transparency
|
||||
shl ecx, 2
|
||||
add ecx, [edx + Image.Palette]
|
||||
mov dword [background_color], 0xFFFFFF ; white background
|
||||
mov dword [ecx], 0xFFFFFF
|
||||
; mov esi, [_data]
|
||||
; test [esi+gif.Header.lsd.Packed], gif.LSD.Packed.GlobalColorTableFlag
|
||||
; jz @f
|
||||
; movzx ecx, [esi+gif.Header.lsd.BackgroundColor]
|
||||
; push ecx
|
||||
; shl ecx, 2
|
||||
; add ecx, [edx + Image.Palette]
|
||||
; mov dword [ecx], 0xFFFFFF
|
||||
; pop ecx
|
||||
; lea ecx, [ecx*3]
|
||||
; add esi, ecx
|
||||
; mov byte [esi+sizeof.gif.Header+0], 0xFF
|
||||
; mov byte [esi+sizeof.gif.Header+1], 0xFF
|
||||
; mov byte [esi+sizeof.gif.Header+2], 0xFF
|
||||
push eax
|
||||
mov eax, [img.decode.gif.options_bgr]
|
||||
mov dword [background_color], eax
|
||||
mov dword [ecx], eax
|
||||
pop eax
|
||||
@@:
|
||||
call img.decode.gif._.is_logical_screen
|
||||
jnz .has_transparency
|
||||
|
371
programs/develop/libraries/libs-dev/libimg/ico_cur/ico_cur.asm
Normal file
371
programs/develop/libraries/libs-dev/libimg/ico_cur/ico_cur.asm
Normal file
@ -0,0 +1,371 @@
|
||||
;;================================================================================================;;
|
||||
;;//// ico.asm //// (c) mike.dld, 2007-2008, (c) diamond, 2009 ///////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; 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. ;;
|
||||
;; ;;
|
||||
;; 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. ;;
|
||||
;; ;;
|
||||
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
|
||||
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; References: ;;
|
||||
;; 1. "Icons in Win32" ;;
|
||||
;; by John Hornick, Microsoft Corporation ;;
|
||||
;; http://msdn2.microsoft.com/en-us/library/ms997538.aspx ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
include 'ico_cur.inc'
|
||||
|
||||
;;================================================================================================;;
|
||||
;;proc img.is.ico _data, _length ;////////////////////////////////////////////////////////////////;;
|
||||
img.is.ico:
|
||||
mov edx, 0x00010000 ; icon type = 1
|
||||
jmp @f
|
||||
img.is.cur:
|
||||
mov edx, 0x00020000 ; cursor type = 2
|
||||
@@:
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Determine if raw data could be decoded (is in ICO format) ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = false / true ;;
|
||||
;;================================================================================================;;
|
||||
; test 1 (length of data): data must contain FileHeader
|
||||
mov ecx, [esp+8]
|
||||
sub ecx, sizeof.ico.FileHeader
|
||||
jb .nope
|
||||
; test 2: signature
|
||||
mov eax, [esp+4]
|
||||
cmp dword [eax], edx ; Reserved & Type
|
||||
jne .nope
|
||||
; test 3: count must be non-zero
|
||||
movzx eax, [eax + ico.FileHeader.Count]
|
||||
test eax, eax
|
||||
jz .nope
|
||||
; test 4 (length of data): data must containt Count dir entries
|
||||
shl eax, 4
|
||||
sub ecx, eax
|
||||
jae .yep
|
||||
|
||||
.nope:
|
||||
xor eax, eax
|
||||
ret 8
|
||||
|
||||
.yep:
|
||||
xor eax, eax
|
||||
inc eax
|
||||
ret 8
|
||||
;endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.decode.ico_cur _data, _length, _options ;////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Decode data into image if it contains correctly formed raw data in ICO/CUR format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;> _options = options for decoding (e.g. background color) ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to image ;;
|
||||
;;================================================================================================;;
|
||||
locals
|
||||
count dd ?
|
||||
img dd ?
|
||||
main_img dd ?
|
||||
endl
|
||||
|
||||
push ebx esi edi
|
||||
|
||||
; img.is.ico has been already called by img.decode
|
||||
; stdcall img.is.ico, [_data], [_length]
|
||||
; or eax, eax
|
||||
; jz .error
|
||||
|
||||
mov ebx, [_data]
|
||||
movzx eax, [ebx + ico.FileHeader.Count]
|
||||
mov [count], eax
|
||||
and [img], 0
|
||||
and [main_img], 0
|
||||
.loop:
|
||||
mov ecx, [ebx + sizeof.ico.FileHeader + ico.DirEntry.ByteSize]
|
||||
mov edx, [ebx + sizeof.ico.FileHeader + ico.DirEntry.ImageOffset]
|
||||
mov eax, [_length]
|
||||
sub eax, edx
|
||||
jb .skip
|
||||
cmp eax, ecx
|
||||
jb .skip
|
||||
cmp ecx, 12 ; length test, see img.is.bmp
|
||||
jb .skip
|
||||
add edx, [_data]
|
||||
push [_options]
|
||||
push ecx
|
||||
push edx
|
||||
call img.decode.ico._.decode_icon_data
|
||||
test eax, eax
|
||||
jz .skip
|
||||
push 0xFFFFFF ; set bgr to white if no given
|
||||
mov edx, [_options]
|
||||
test edx, edx
|
||||
jz @f
|
||||
cmp [edx + ImageDecodeOptions.UsedSize], ImageDecodeOptions.BackgroundColor + 4
|
||||
jb @f
|
||||
add esp, 4
|
||||
push [edx + ImageDecodeOptions.BackgroundColor]
|
||||
@@:
|
||||
call img.decode.ico._.decode_icon_mask
|
||||
test eax, eax
|
||||
jz .skip
|
||||
mov edx, [img]
|
||||
test edx, edx
|
||||
jz .first
|
||||
mov [edx + Image.Next], eax
|
||||
mov [eax + Image.Previous], edx
|
||||
jmp @f
|
||||
.first:
|
||||
mov [main_img], eax
|
||||
@@:
|
||||
mov [img], eax
|
||||
.skip:
|
||||
add ebx, sizeof.ico.DirEntry
|
||||
dec [count]
|
||||
jnz .loop
|
||||
|
||||
mov eax, [main_img]
|
||||
pop edi esi ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
img.encode.cur:
|
||||
proc img.encode.ico _img, _p_length, _options ;///////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Encode image into raw data in ICO format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _img = pointer to image ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to encoded data ;;
|
||||
;< _p_length = encoded data length ;;
|
||||
;;================================================================================================;;
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below are private procs you should never call directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
|
||||
img.decode.ico._.decode_icon_data:
|
||||
; create stack frame and jump to common BMP+ICO code
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
sub esp, 12
|
||||
mov byte [ebp - 3], 1 ; bIsIco
|
||||
jmp img.decode.bmp.common
|
||||
|
||||
img.decode.ico._.decode_icon_mask:
|
||||
mov edx, [eax + Image.Width]
|
||||
add edx, 31
|
||||
shr edx, 3
|
||||
and edx, not 3
|
||||
push edx
|
||||
imul edx, [eax + Image.Height]
|
||||
cmp ecx, edx
|
||||
pop edx
|
||||
jb .error.free
|
||||
mov edi, [eax + Image.Data]
|
||||
push ebp ebx eax
|
||||
xor ebp, ebp
|
||||
mov ebx, [eax + Image.Extended]
|
||||
cmp [ebx + bmp.Image.info.Height], 0
|
||||
js @f
|
||||
push edx
|
||||
imul edx, [eax + Image.Height]
|
||||
add esi, edx
|
||||
pop edx
|
||||
lea ebp, [edx+edx]
|
||||
sub esi, edx
|
||||
@@:
|
||||
mov ebx, [eax + Image.Height]
|
||||
mov ecx, [eax + Image.Width]
|
||||
; for now, BMP code produces only 8 and 32 bpp images
|
||||
cmp [eax + Image.Type], Image.bpp8
|
||||
jz .bpp8
|
||||
.bpp32:
|
||||
mov edx, [esp+16] ; get background color
|
||||
.bpp32.extloop:
|
||||
push ecx
|
||||
.bpp32.innloop:
|
||||
lodsd
|
||||
bswap eax
|
||||
push 32
|
||||
.bpp32.dwordloop:
|
||||
add eax, eax
|
||||
jnc @f
|
||||
mov [edi], edx
|
||||
@@:
|
||||
add edi, 4
|
||||
dec ecx
|
||||
jz @f
|
||||
dec dword [esp]
|
||||
jnz .bpp32.dwordloop
|
||||
@@:
|
||||
pop eax
|
||||
test ecx, ecx
|
||||
jnz .bpp32.innloop
|
||||
sub esi, ebp
|
||||
pop ecx
|
||||
dec ebx
|
||||
jnz .bpp32.extloop
|
||||
pop eax ebx ebp
|
||||
ret 4
|
||||
.bpp8:
|
||||
push edi
|
||||
mov edi, [eax + Image.Palette]
|
||||
mov eax, [esp+20] ; get background color
|
||||
; if palette already has index for bgr color, use it
|
||||
push ecx
|
||||
mov ecx, 256
|
||||
repnz scasd
|
||||
jnz .bpp8.notfound
|
||||
not cl ; cl = index
|
||||
pop edx
|
||||
pop edi
|
||||
.bpp8.extloop:
|
||||
push edx
|
||||
.bpp8.innloop:
|
||||
lodsd
|
||||
bswap eax
|
||||
push 32
|
||||
.bpp8.dwordloop:
|
||||
add eax, eax
|
||||
jnc @f
|
||||
mov [edi], cl
|
||||
@@:
|
||||
inc edi
|
||||
dec edx
|
||||
jz @f
|
||||
dec dword [esp]
|
||||
jnz .bpp8.dwordloop
|
||||
@@:
|
||||
pop eax
|
||||
test edx, edx
|
||||
jnz .bpp8.innloop
|
||||
sub esi, ebp
|
||||
pop edx
|
||||
dec ebx
|
||||
jnz .bpp8.extloop
|
||||
pop eax ebx ebp
|
||||
ret 4
|
||||
.bpp8.notfound:
|
||||
; get maximum used color; if index < 255, then we can add one color to palette
|
||||
pop ecx
|
||||
pop edi
|
||||
pop eax
|
||||
mov edx, [eax + Image.Width]
|
||||
imul edx, ebx
|
||||
mov edi, [eax + Image.Data]
|
||||
xor ecx, ecx
|
||||
.bpp8.scanloop:
|
||||
cmp [edi], cl
|
||||
jb @f
|
||||
mov cl, [edi]
|
||||
@@:
|
||||
inc edi
|
||||
dec edx
|
||||
jnz .bpp8.scanloop
|
||||
inc cl
|
||||
jz .bpp8.nospace
|
||||
mov edx, [esp+8]
|
||||
mov edi, [eax + Image.Palette]
|
||||
mov [edi+ecx*4], edx ; set palette color
|
||||
mov edi, [eax + Image.Data]
|
||||
mov edx, [eax + Image.Width]
|
||||
push eax
|
||||
jmp .bpp8.extloop
|
||||
.bpp8.nospace:
|
||||
; convert to 24 bpp
|
||||
mov edx, [eax + Image.Width]
|
||||
imul edx, ebx
|
||||
lea edx, [edx*3]
|
||||
push eax
|
||||
invoke mem.alloc, edx
|
||||
mov edi, eax
|
||||
pop eax
|
||||
test edi, edi
|
||||
jz .error.free2
|
||||
push eax esi edi
|
||||
mov esi, eax
|
||||
call img._.do_rgb
|
||||
pop edi esi eax
|
||||
xchg edi, [eax + Image.Data]
|
||||
mov byte [eax + Image.Type], Image.bpp24
|
||||
push eax
|
||||
invoke mem.free, edi
|
||||
pop eax
|
||||
push eax
|
||||
mov ecx, [eax + Image.Width]
|
||||
.bpp24:
|
||||
mov edx, [esp+16] ; get background color
|
||||
.bpp24.extloop:
|
||||
push ecx
|
||||
.bpp24.innloop:
|
||||
lodsd
|
||||
bswap eax
|
||||
push 32
|
||||
.bpp24.dwordloop:
|
||||
add eax, eax
|
||||
jnc @f
|
||||
mov [edi], dx
|
||||
ror edx, 16
|
||||
mov [edi+2], dl
|
||||
ror edx, 16
|
||||
@@:
|
||||
add edi, 4
|
||||
dec ecx
|
||||
jz @f
|
||||
dec dword [esp]
|
||||
jnz .bpp24.dwordloop
|
||||
@@:
|
||||
pop eax
|
||||
test ecx, ecx
|
||||
jnz .bpp24.innloop
|
||||
sub esi, ebp
|
||||
pop ecx
|
||||
dec ebx
|
||||
jnz .bpp24.extloop
|
||||
pop eax ebx ebp
|
||||
ret 4
|
||||
.error.free2:
|
||||
pop ebx ebp
|
||||
.error.free:
|
||||
stdcall img._.delete, eax
|
||||
xor eax, eax
|
||||
ret 4
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below is private data you should never use directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
|
||||
|
||||
;
|
@ -1,5 +1,5 @@
|
||||
;;================================================================================================;;
|
||||
;;//// ico.asm //// (c) mike.dld, 2007-2008 //////////////////////////////////////////////////////;;
|
||||
;;//// ico.inc //// (c) diamond, 2009 ////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; This file is part of Common development libraries (Libs-Dev). ;;
|
||||
@ -16,10 +16,31 @@
|
||||
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; References: ;;
|
||||
;; 1. "Icons in Win32" ;;
|
||||
;; by John Hornick, Microsoft Corporation ;;
|
||||
;; http://msdn2.microsoft.com/en-us/library/ms997538.aspx ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
struct ico.FileHeader
|
||||
Reserved dw ? ; must be 0
|
||||
Type dw ? ; must be 1
|
||||
Count dw ?
|
||||
ends
|
||||
|
||||
struct ico.DirEntry
|
||||
Width db ?
|
||||
Height db ?
|
||||
ColorCount db ?
|
||||
db ? ; reseved
|
||||
dw ? ; reserved
|
||||
dw ? ; reserved
|
||||
ByteSize dd ?
|
||||
ImageOffset dd ?
|
||||
ends
|
||||
|
||||
struct cur.DirEntry
|
||||
Width db ?
|
||||
Height db ?
|
||||
ColorCount db ?
|
||||
db ? ; reserved
|
||||
XHotSpot dw ?
|
||||
YHotSpot dw ?
|
||||
ByteSize dd ?
|
||||
ImageOffset dd ?
|
||||
ends
|
@ -69,7 +69,7 @@ img.decode.jpg:
|
||||
.ret:
|
||||
mov [esp+28], eax
|
||||
popad
|
||||
ret 8
|
||||
ret 12
|
||||
.soi_ok:
|
||||
mov [ebx + jpeg.work.restart_interval], ecx
|
||||
mov [ebx + jpeg.work.adobe_ycck], cl
|
||||
|
@ -37,6 +37,7 @@ include 'jpeg/jpeg.asm'
|
||||
include 'png/png.asm'
|
||||
include 'tga/tga.asm'
|
||||
include 'z80/z80.asm'
|
||||
include 'ico_cur/ico_cur.asm'
|
||||
|
||||
;;================================================================================================;;
|
||||
proc lib_init ;///////////////////////////////////////////////////////////////////////////////////;;
|
||||
@ -496,7 +497,7 @@ align 16
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.decode _data, _length ;//////////////////////////////////////////////////////////////////;;
|
||||
proc img.decode _data, _length, _options ;////////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? --- TBD --- ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
@ -510,17 +511,18 @@ proc img.decode _data, _length ;////////////////////////////////////////////////
|
||||
or eax, eax
|
||||
jnz @f
|
||||
add ebx, sizeof.FormatsTableEntry
|
||||
cmp dword[ebx], 0
|
||||
cmp dword[ebx], eax ;0
|
||||
jnz @b
|
||||
jmp .error
|
||||
@@: stdcall [ebx + FormatsTableEntry.Decode], [_data], [_length]
|
||||
|
||||
.error:
|
||||
pop ebx
|
||||
ret
|
||||
@@: mov eax, [ebx + FormatsTableEntry.Decode]
|
||||
pop ebx
|
||||
leave
|
||||
jmp eax
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.encode _img, _p_length ;/////////////////////////////////////////////////////////////////;;
|
||||
proc img.encode _img, _p_length, _options ;///////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? --- TBD --- ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
@ -1667,8 +1669,8 @@ img._.get_scanline_len: ;///////////////////////////////////////////////////////
|
||||
align 4
|
||||
img._.formats_table:
|
||||
.bmp dd img.is.bmp, img.decode.bmp, img.encode.bmp
|
||||
; .ico dd img.is.ico, img.decode.ico, img.encode.ico
|
||||
; .cur dd img.is.cur, img.decode.cur, img.encode.cur
|
||||
.ico dd img.is.ico, img.decode.ico_cur, img.encode.ico
|
||||
.cur dd img.is.cur, img.decode.ico_cur, img.encode.cur
|
||||
.gif dd img.is.gif, img.decode.gif, img.encode.gif
|
||||
.png dd img.is.png, img.decode.png, img.encode.png
|
||||
.jpg dd img.is.jpg, img.decode.jpg, img.encode.jpg
|
||||
@ -1707,35 +1709,35 @@ align 4
|
||||
|
||||
export \
|
||||
lib_init , 'lib_init' , \
|
||||
0x00010004 , 'version' , \
|
||||
img.is_img , 'img.is_img' , \
|
||||
img.info , 'img.info' , \
|
||||
img.from_file , 'img.from_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.destroy.layer, 'img.destroy.layer', \
|
||||
img.count , 'img.count' , \
|
||||
img.lock_bits , 'img.lock_bits' , \
|
||||
img.unlock_bits , 'img.unlock_bits' , \
|
||||
img.flip , 'img.flip' , \
|
||||
img.flip.layer , 'img.flip.layer' , \
|
||||
img.rotate , 'img.rotate' , \
|
||||
img.rotate.layer, 'img.rotate.layer', \
|
||||
img.draw , 'img.draw'
|
||||
0x00050005 , 'version' , \
|
||||
img.is_img , 'img_is_img' , \
|
||||
img.info , 'img_info' , \
|
||||
img.from_file , 'img_from_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.destroy.layer, 'img_destroy_layer', \
|
||||
img.count , 'img_count' , \
|
||||
img.lock_bits , 'img_lock_bits' , \
|
||||
img.unlock_bits , 'img_unlock_bits' , \
|
||||
img.flip , 'img_flip' , \
|
||||
img.flip.layer , 'img_flip_layer' , \
|
||||
img.rotate , 'img_rotate' , \
|
||||
img.rotate.layer, 'img_rotate_layer', \
|
||||
img.draw , 'img_draw'
|
||||
|
||||
; import from deflate unpacker
|
||||
; is initialized only when PNG loading is requested
|
||||
align 4
|
||||
@IMPORT:
|
||||
|
||||
library kfar_arc, '../File Managers/kfar_arc.obj'
|
||||
import kfar_arc, \
|
||||
library archiver, 'archiver.obj'
|
||||
import archiver, \
|
||||
deflate_unpack2, 'deflate_unpack2'
|
||||
|
||||
align 4
|
||||
|
@ -49,6 +49,11 @@ Image.bpp16 = 5
|
||||
; bits in Image.Flags
|
||||
Image.IsAnimated = 1
|
||||
|
||||
struct ImageDecodeOptions
|
||||
UsedSize dd ? ; if >=8, the field BackgroundColor is valid, and so on
|
||||
BackgroundColor dd ? ; used for transparent images as background
|
||||
ends
|
||||
|
||||
FLIP_VERTICAL = 0x01
|
||||
FLIP_HORIZONTAL = 0x02
|
||||
FLIP_BOTH = FLIP_VERTICAL or FLIP_HORIZONTAL
|
||||
|
@ -49,7 +49,7 @@ img.is.png:
|
||||
;endp
|
||||
|
||||
;;================================================================================================;;
|
||||
;;proc img.decode.png _data, _length ;////////////////////////////////////////////////////////////;;
|
||||
;;proc img.decode.png _data, _length, _options ;//////////////////////////////////////////////////;;
|
||||
img.decode.png:
|
||||
xor eax, eax ; .image = 0
|
||||
pushad
|
||||
@ -76,6 +76,7 @@ virtual at ebp - .localsize
|
||||
rd 1
|
||||
.data dd ?
|
||||
.length dd ?
|
||||
.options dd ?
|
||||
end virtual
|
||||
push 0 ; .idat_read = 0
|
||||
sub esp, .localsize-4
|
||||
@ -99,7 +100,7 @@ end virtual
|
||||
add esp, .localsize
|
||||
popad
|
||||
mov [deflate_loader_mutex], eax
|
||||
ret
|
||||
ret 12
|
||||
.deflate_loaded:
|
||||
; release mutex
|
||||
mov [deflate_loader_mutex], 0
|
||||
@ -229,7 +230,7 @@ end virtual
|
||||
.eof:
|
||||
add esp, .localsize
|
||||
popad
|
||||
ret
|
||||
ret 12
|
||||
; PLTE chunk
|
||||
.palette:
|
||||
mov eax, [.image]
|
||||
@ -876,4 +877,4 @@ end repeat
|
||||
|
||||
img.encode.png:
|
||||
xor eax, eax
|
||||
ret 8
|
||||
ret 12
|
||||
|
@ -78,7 +78,7 @@ proc img.is.tga _data, _length ;////////////////////////////////////////////////
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.decode.tga _data, _length ;//////////////////////////////////////////////////////////////;;
|
||||
proc img.decode.tga _data, _length, _options ;////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Decode data into image if it contains correctly formed raw data in Targa format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
@ -217,7 +217,7 @@ endl
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.encode.tga _img, _p_length ;/////////////////////////////////////////////////////////////;;
|
||||
proc img.encode.tga _img, _p_length, _options ;///////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Encode image into raw data in Targa format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
|
@ -45,7 +45,7 @@ proc img.is.z80 _data, _length ;////////////////////////////////////////////////
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.decode.z80 _data, _length ;//////////////////////////////////////////////////////////////;;
|
||||
proc img.decode.z80 _data, _length, _options ;////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Decode data into image if it contains correctly formed raw data in z80 screen format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
@ -209,7 +209,7 @@ img.decode.z80.failed:
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.encode.z80 _img, _p_length ;/////////////////////////////////////////////////////////////;;
|
||||
proc img.encode.z80 _img, _p_length, _options ;///////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Encode image into raw data in z80 screen format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
|
@ -674,15 +674,15 @@ library \
|
||||
libio , 'libio.obj'
|
||||
|
||||
import libio , \
|
||||
file.size , 'file.size' , \
|
||||
file.open , 'file.open' , \
|
||||
file.read , 'file.read' , \
|
||||
file.write , 'file.write' , \
|
||||
file.seek , 'file.seek' , \
|
||||
file.eof? , 'file.eof?' , \
|
||||
file.seteof , 'file.seteof' , \
|
||||
file.tell , 'file.tell' , \
|
||||
file.close , 'file.close'
|
||||
file.size , 'file_size' , \
|
||||
file.open , 'file_open' , \
|
||||
file.read , 'file_read' , \
|
||||
file.write , 'file_write' , \
|
||||
file.seek , 'file_seek' , \
|
||||
file.eof? , 'file_iseof' , \
|
||||
file.seteof , 'file_seteof' , \
|
||||
file.tell , 'file_tell' , \
|
||||
file.close , 'file_close'
|
||||
|
||||
|
||||
;;================================================================================================;;
|
||||
@ -699,12 +699,12 @@ align 16
|
||||
|
||||
export \
|
||||
libini._.init , 'lib_init' , \
|
||||
0x00040007 , 'version' , \
|
||||
ini.enum_sections , 'ini.enum_sections' , \
|
||||
ini.enum_keys , 'ini.enum_keys' , \
|
||||
ini.get_str , 'ini.get_str' , \
|
||||
ini.get_int , 'ini.get_int' , \
|
||||
ini.get_color , 'ini.get_color' , \
|
||||
ini.set_str , 'ini.set_str' , \
|
||||
ini.set_int , 'ini.set_int' , \
|
||||
ini.set_color , 'ini.set_color'
|
||||
0x00080008 , 'version' , \
|
||||
ini.enum_sections , 'ini_enum_sections' , \
|
||||
ini.enum_keys , 'ini_enum_keys' , \
|
||||
ini.get_str , 'ini_get_str' , \
|
||||
ini.get_int , 'ini_get_int' , \
|
||||
ini.get_color , 'ini_get_color' , \
|
||||
ini.set_str , 'ini_set_str' , \
|
||||
ini.set_int , 'ini_set_int' , \
|
||||
ini.set_color , 'ini_set_color'
|
||||
|
@ -534,17 +534,17 @@ align 16
|
||||
|
||||
export \
|
||||
libio._.init , 'lib_init' , \
|
||||
0x00030003 , 'version' , \
|
||||
file.find_first , 'file.find_first' , \
|
||||
file.find_next , 'file.find_next' , \
|
||||
file.find_close , 'file.find_close' , \
|
||||
file.size , 'file.size' , \
|
||||
file.open , 'file.open' , \
|
||||
file.read , 'file.read' , \
|
||||
file.write , 'file.write' , \
|
||||
file.seek , 'file.seek' , \
|
||||
file.tell , 'file.tell' , \
|
||||
file.eof? , 'file.eof?' , \
|
||||
file.seteof , 'file.seteof' , \
|
||||
file.truncate , 'file.truncate' , \
|
||||
file.close , 'file.close'
|
||||
0x00040004 , 'version' , \
|
||||
file.find_first , 'file_find_first' , \
|
||||
file.find_next , 'file_find_next' , \
|
||||
file.find_close , 'file_find_close' , \
|
||||
file.size , 'file_size' , \
|
||||
file.open , 'file_open' , \
|
||||
file.read , 'file_read' , \
|
||||
file.write , 'file_write' , \
|
||||
file.seek , 'file_seek' , \
|
||||
file.tell , 'file_tell' , \
|
||||
file.eof? , 'file_iseof' , \
|
||||
file.seteof , 'file_seteof' , \
|
||||
file.truncate , 'file_truncate' , \
|
||||
file.close , 'file_close'
|
||||
|
@ -528,44 +528,44 @@ library \
|
||||
libgfx,'libgfx.obj'
|
||||
|
||||
import libini, \
|
||||
ini.get_str ,'ini.get_str',\
|
||||
ini.set_str ,'ini.set_str',\
|
||||
ini.get_int ,'ini.get_int',\
|
||||
ini.set_int ,'ini.set_int',\
|
||||
ini.get_color,'ini.get_color',\
|
||||
ini.set_color,'ini.set_color'
|
||||
ini.get_str ,'ini_get_str',\
|
||||
ini.set_str ,'ini_set_str',\
|
||||
ini.get_int ,'ini_get_int',\
|
||||
ini.set_int ,'ini_set_int',\
|
||||
ini.get_color,'ini_get_color',\
|
||||
ini.set_color,'ini_set_color'
|
||||
|
||||
import libio, \
|
||||
file.find_first,'file.find_first',\
|
||||
file.find_next ,'file.find_next',\
|
||||
file.find_close,'file.find_close',\
|
||||
file.size ,'file.size',\
|
||||
file.open ,'file.open',\
|
||||
file.read ,'file.read',\
|
||||
file.write ,'file.write',\
|
||||
file.seek ,'file.seek',\
|
||||
file.tell ,'file.tell',\
|
||||
file.eof? ,'file.eof?',\
|
||||
file.truncate ,'file.truncate',\
|
||||
file.close ,'file.close'
|
||||
file.find_first,'file_find_first',\
|
||||
file.find_next ,'file_find_next',\
|
||||
file.find_close,'file_find_close',\
|
||||
file.size ,'file_size',\
|
||||
file.open ,'file_open',\
|
||||
file.read ,'file_read',\
|
||||
file.write ,'file_write',\
|
||||
file.seek ,'file_seek',\
|
||||
file.tell ,'file_tell',\
|
||||
file.eof? ,'file_iseof',\
|
||||
file.truncate ,'file_truncate',\
|
||||
file.close ,'file_close'
|
||||
|
||||
import libgfx, \
|
||||
gfx.open ,'gfx.open',\
|
||||
gfx.close ,'gfx.close',\
|
||||
gfx.pen.color ,'gfx.pen.color',\
|
||||
gfx.brush.color ,'gfx.brush.color',\
|
||||
gfx.pixel ,'gfx.pixel',\
|
||||
gfx.move.to ,'gfx.move.to',\
|
||||
gfx.line.to ,'gfx.line.to',\
|
||||
gfx.line ,'gfx.line',\
|
||||
gfx.polyline ,'gfx.polyline',\
|
||||
gfx.polyline.to ,'gfx.polyline.to',\
|
||||
gfx.fillrect ,'gfx.fillrect',\
|
||||
gfx.fillrect.ex ,'gfx.fillrect.ex',\
|
||||
gfx.framerect ,'gfx.framerect',\
|
||||
gfx.framerect.ex,'gfx.framerect.ex',\
|
||||
gfx.rectangle ,'gfx.rectangle',\
|
||||
gfx.rectangle.ex,'gfx.rectangle.ex'
|
||||
gfx.open ,'gfx_open',\
|
||||
gfx.close ,'gfx_close',\
|
||||
gfx.pen.color ,'gfx_pen_color',\
|
||||
gfx.brush.color ,'gfx_brush_color',\
|
||||
gfx.pixel ,'gfx_pixel',\
|
||||
gfx.move.to ,'gfx_move_to',\
|
||||
gfx.line.to ,'gfx_line_to',\
|
||||
gfx.line ,'gfx_line',\
|
||||
gfx.polyline ,'gfx_polyline',\
|
||||
gfx.polyline.to ,'gfx_polyline_to',\
|
||||
gfx.fillrect ,'gfx_fillrect',\
|
||||
gfx.fillrect.ex ,'gfx_fillrect_ex',\
|
||||
gfx.framerect ,'gfx_framerect',\
|
||||
gfx.framerect.ex,'gfx_framerect_ex',\
|
||||
gfx.rectangle ,'gfx_rectangle',\
|
||||
gfx.rectangle.ex,'gfx_rectangle_ex'
|
||||
|
||||
TINYPAD_END: ; end of file
|
||||
|
||||
|
@ -160,8 +160,8 @@ start:
|
||||
; load libini.obj and kfar.ini
|
||||
mov eax, libini_name
|
||||
mov esi, ini_import
|
||||
push 6
|
||||
pop ebp ; we use version 6 of libini
|
||||
push 8
|
||||
pop ebp ; we use version 8 of libini
|
||||
call load_dll_and_import
|
||||
test eax, eax
|
||||
jnz .noini
|
||||
@ -8343,10 +8343,10 @@ standard_dll_path_size = $ - standard_dll_path
|
||||
aStart db 'START',0
|
||||
aLibInit db 'lib_init',0
|
||||
aVersion db 'version',0
|
||||
aIniGetInt db 'ini.get_int',0
|
||||
aIniGetStr db 'ini.get_str',0
|
||||
aIniSetInt db 'ini.set_int',0
|
||||
aIniEnumKeys db 'ini.enum_keys',0
|
||||
aIniGetInt db 'ini_get_int',0
|
||||
aIniGetStr db 'ini_get_str',0
|
||||
aIniSetInt db 'ini_set_int',0
|
||||
aIniEnumKeys db 'ini_enum_keys',0
|
||||
aPluginLoad db 'plugin_load',0
|
||||
aPluginUnload db 'plugin_unload',0
|
||||
aGetattr db 'getattr',0
|
||||
|
@ -231,7 +231,7 @@ load_image:
|
||||
; invoke img.is_img, [img_data], [img_data_len]
|
||||
; or eax, eax
|
||||
; jz exit
|
||||
invoke img.decode, [img_data], [img_data_len]
|
||||
invoke img.decode, [img_data], [img_data_len], 0
|
||||
or eax, eax
|
||||
jz .error
|
||||
cmp [image], 0
|
||||
@ -513,6 +513,10 @@ load_directory:
|
||||
jz .copy
|
||||
cmp ecx, 'jpe'
|
||||
jz .copy
|
||||
cmp ecx, 'ico'
|
||||
jz .copy
|
||||
cmp ecx, 'cur'
|
||||
jz .copy
|
||||
cmp ecx, 'jpeg'
|
||||
jz @f
|
||||
cmp ecx, 'jpeG'
|
||||
@ -722,6 +726,41 @@ draw_cur_frame:
|
||||
push 5 ; x
|
||||
push [cur_frame]
|
||||
call [img.draw]
|
||||
mov eax, [image]
|
||||
test [eax + Image.Flags], Image.IsAnimated
|
||||
jnz .done
|
||||
cmp [eax + Image.Next], 0
|
||||
jnz .additional_frames
|
||||
.done:
|
||||
ret
|
||||
.additional_frames:
|
||||
mov ebx, [procinfo+62]
|
||||
sub ebx, 4
|
||||
jbe .done
|
||||
push 5
|
||||
pop esi
|
||||
.afloop:
|
||||
sub ebx, [eax + Image.Width]
|
||||
jbe .done
|
||||
dec ebx
|
||||
jz .done
|
||||
add esi, [eax + Image.Width]
|
||||
mov eax, [eax + Image.Next]
|
||||
push eax
|
||||
inc esi
|
||||
push 0 ; ypos
|
||||
push 0 ; xpos
|
||||
mov ecx, [procinfo+66]
|
||||
sub ecx, 34
|
||||
push ecx ; max height
|
||||
push ebx ; max width
|
||||
push 35 ; y
|
||||
push esi ; x
|
||||
push eax ; image
|
||||
call [img.draw]
|
||||
pop eax
|
||||
cmp [eax + Image.Next], 0
|
||||
jnz .afloop
|
||||
ret
|
||||
|
||||
; void* __stdcall mem.Alloc(unsigned size);
|
||||
@ -961,27 +1000,27 @@ library \
|
||||
|
||||
import libio , \
|
||||
libio.init , 'lib_init' , \
|
||||
file.size , 'file.size' , \
|
||||
file.open , 'file.open' , \
|
||||
file.read , 'file.read' , \
|
||||
file.close , 'file.close'
|
||||
file.size , 'file_size' , \
|
||||
file.open , 'file_open' , \
|
||||
file.read , 'file_read' , \
|
||||
file.close , 'file_close'
|
||||
|
||||
import libgfx , \
|
||||
libgfx.init , 'lib_init' , \
|
||||
gfx.open , 'gfx.open' , \
|
||||
gfx.close , 'gfx.close' , \
|
||||
gfx.pen.color , 'gfx.pen.color' , \
|
||||
gfx.line , 'gfx.line'
|
||||
gfx.open , 'gfx_open' , \
|
||||
gfx.close , 'gfx_close' , \
|
||||
gfx.pen.color , 'gfx_pen_color' , \
|
||||
gfx.line , 'gfx_line'
|
||||
|
||||
import libimg , \
|
||||
libimg.init , 'lib_init' , \
|
||||
img.is_img , 'img.is_img' , \
|
||||
img.to_rgb2 , 'img.to_rgb2', \
|
||||
img.decode , 'img.decode' , \
|
||||
img.flip , 'img.flip' , \
|
||||
img.rotate , 'img.rotate' , \
|
||||
img.destroy , 'img.destroy', \
|
||||
img.draw , 'img.draw'
|
||||
img.is_img , 'img_is_img' , \
|
||||
img.to_rgb2 , 'img_to_rgb2', \
|
||||
img.decode , 'img_decode' , \
|
||||
img.flip , 'img_flip' , \
|
||||
img.rotate , 'img_rotate' , \
|
||||
img.destroy , 'img_destroy', \
|
||||
img.draw , 'img_draw'
|
||||
|
||||
import sort, sort.START, 'START', SortDir, 'SortDir', strcmpi, 'strcmpi'
|
||||
|
||||
|
@ -453,7 +453,7 @@ library \
|
||||
libini,'libini.obj'
|
||||
|
||||
import libini, \
|
||||
ini.get_str,'ini.get_str'
|
||||
ini.get_str,'ini_get_str'
|
||||
|
||||
include_debug_strings
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user