forked from KolibriOS/kolibrios
libimg: bmp support improved, jpeg support added
git-svn-id: svn://kolibrios.org@999 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
0be9a1a504
commit
e2b2bba7ba
@ -1,19 +1,19 @@
|
|||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
;;//// bmp.asm //// (c) mike.dld, 2007-2008 //////////////////////////////////////////////////////;;
|
;;//// bmp.asm //// (c) mike.dld, 2007-2008, (c) diamond, 2009 ///////////////////////////////////;;
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; 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 ;;
|
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
|
||||||
;; General Public License as published by the Free Software Foundation, either version 3 of the ;;
|
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
|
||||||
;; 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 ;;
|
;; 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 ;;
|
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
|
||||||
;; General Public License for more details. ;;
|
;; Lesser General Public License for more details. ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
|
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
|
||||||
;; see <http://www.gnu.org/licenses/>. ;;
|
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
;; ;;
|
;; ;;
|
||||||
@ -28,7 +28,8 @@
|
|||||||
include 'bmp.inc'
|
include 'bmp.inc'
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
proc img.is.bmp _data, _length ;//////////////////////////////////////////////////////////////////;;
|
;;proc img.is.bmp _data, _length ;////////////////////////////////////////////////////////////////;;
|
||||||
|
img.is.bmp:
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
;? Determine if raw data could be decoded (is in BMP format) ;;
|
;? Determine if raw data could be decoded (is in BMP format) ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
@ -37,21 +38,23 @@ proc img.is.bmp _data, _length ;////////////////////////////////////////////////
|
|||||||
;;------------------------------------------------------------------------------------------------;;
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
;< eax = false / true ;;
|
;< eax = false / true ;;
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
cmp [_length], 2
|
; test 1 (length of data): data must contain FileHeader and required fields from InfoHeader
|
||||||
|
cmp dword [esp+8], sizeof.bmp.FileHeader + 12
|
||||||
jb .nope
|
jb .nope
|
||||||
mov eax, [_data]
|
; test 2: signature
|
||||||
cmp word[eax], 'BM'
|
mov eax, [esp+4]
|
||||||
|
cmp word [eax], 'BM'
|
||||||
je .yep
|
je .yep
|
||||||
|
|
||||||
.nope:
|
.nope:
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret 8
|
||||||
|
|
||||||
.yep:
|
.yep:
|
||||||
xor eax,eax
|
xor eax, eax
|
||||||
inc eax
|
inc eax
|
||||||
ret
|
ret 8
|
||||||
endp
|
;endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
proc img.decode.bmp _data, _length ;//////////////////////////////////////////////////////////////;;
|
proc img.decode.bmp _data, _length ;//////////////////////////////////////////////////////////////;;
|
||||||
@ -65,13 +68,15 @@ proc img.decode.bmp _data, _length ;////////////////////////////////////////////
|
|||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
locals
|
locals
|
||||||
img dd ?
|
img dd ?
|
||||||
|
bTopDown db ?
|
||||||
endl
|
endl
|
||||||
|
|
||||||
push ebx
|
push ebx esi edi
|
||||||
|
|
||||||
stdcall img.is.bmp, [_data], [_length]
|
; img.is.bmp has been already called by img.decode
|
||||||
or eax, eax
|
; stdcall img.is.bmp, [_data], [_length]
|
||||||
jz .error
|
; or eax, eax
|
||||||
|
; jz .error
|
||||||
|
|
||||||
mov ebx, [_data]
|
mov ebx, [_data]
|
||||||
; cmp [ebx + bmp.Header.info.Compression], bmp.BI_RGB
|
; cmp [ebx + bmp.Header.info.Compression], bmp.BI_RGB
|
||||||
@ -79,8 +84,60 @@ endl
|
|||||||
; mov eax, [ebx + bmp.Header.file.Size]
|
; mov eax, [ebx + bmp.Header.file.Size]
|
||||||
; cmp eax, [_length]
|
; cmp eax, [_length]
|
||||||
; jne .error
|
; jne .error
|
||||||
|
; @@:
|
||||||
|
|
||||||
|
mov eax, [ebx + bmp.Header.info.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
|
||||||
|
jz .old1
|
||||||
|
cmp eax, sizeof.bmp.FileHeader + 40
|
||||||
|
jz .normal
|
||||||
|
cmp eax, sizeof.bmp.FileHeader + 56
|
||||||
|
jnz .error
|
||||||
|
; convert images with <= 8 bpp to 8bpp, other - to 32 bpp
|
||||||
|
.normal:
|
||||||
|
xor eax, eax
|
||||||
|
inc eax ; Image.bpp8
|
||||||
|
cmp [ebx + bmp.Header.info.BitCount], 8
|
||||||
|
jbe @f
|
||||||
|
mov al, Image.bpp32
|
||||||
|
@@:
|
||||||
|
push eax
|
||||||
|
mov eax, [ebx + bmp.Header.info.Height]
|
||||||
|
test eax, eax
|
||||||
|
jns @f
|
||||||
|
inc [bTopDown]
|
||||||
|
neg eax
|
||||||
|
@@:
|
||||||
|
pushd eax
|
||||||
|
pushd [ebx + bmp.Header.info.Width]
|
||||||
|
jmp .create
|
||||||
|
.old1:
|
||||||
|
xor eax, eax
|
||||||
|
inc eax ; Image.bpp8
|
||||||
|
cmp [ebx + bmp.Header.info.OldBitCount], 8
|
||||||
|
jbe @f
|
||||||
|
mov al, Image.bpp32
|
||||||
|
@@:
|
||||||
|
push eax
|
||||||
|
movsx eax, [ebx + bmp.Header.info.OldHeight]
|
||||||
|
test eax, eax
|
||||||
|
jns @f
|
||||||
|
inc [bTopDown]
|
||||||
|
neg eax
|
||||||
|
@@:
|
||||||
|
push eax
|
||||||
|
movzx eax, [ebx + bmp.Header.info.OldWidth]
|
||||||
|
push eax
|
||||||
|
.create:
|
||||||
|
call img.create
|
||||||
|
|
||||||
@@: stdcall img.create, [ebx + bmp.Header.info.Width], [ebx + bmp.Header.info.Height]
|
|
||||||
or eax, eax
|
or eax, eax
|
||||||
jz .error
|
jz .error
|
||||||
mov [img], eax
|
mov [img], eax
|
||||||
@ -88,52 +145,87 @@ endl
|
|||||||
|
|
||||||
invoke mem.alloc, sizeof.bmp.Image
|
invoke mem.alloc, sizeof.bmp.Image
|
||||||
or eax, eax
|
or eax, eax
|
||||||
jz .error
|
jz .error.free
|
||||||
mov [edx + Image.Extended], eax
|
mov [edx + Image.Extended], eax
|
||||||
mov esi, ebx
|
push eax
|
||||||
add esi, sizeof.bmp.FileHeader
|
|
||||||
mov edi, eax
|
mov edi, eax
|
||||||
mov ecx, sizeof.bmp.InfoHeader
|
mov ecx, sizeof.bmp.Image/4
|
||||||
|
xor eax, eax
|
||||||
|
rep stosd
|
||||||
|
pop edi
|
||||||
|
lea esi, [ebx + sizeof.bmp.FileHeader]
|
||||||
|
pushd [ebx + bmp.FileHeader.OffBits]
|
||||||
|
mov ecx, [esi + bmp.InfoHeader.Size]
|
||||||
|
cmp ecx, 12
|
||||||
|
jz .old2
|
||||||
rep movsb
|
rep movsb
|
||||||
|
jmp .decode
|
||||||
|
.old2:
|
||||||
|
movsd ; Size
|
||||||
|
movzx eax, word [esi] ; OldWidth -> Width
|
||||||
|
stosd
|
||||||
|
movsx eax, word [esi+2] ; OldHeight -> Height
|
||||||
|
stosd
|
||||||
|
lodsd ; skip OldWidth+OldHeight
|
||||||
|
movsd ; Planes+BitCount
|
||||||
|
.decode:
|
||||||
|
|
||||||
mov eax, [ebx + bmp.Header.info.Compression]
|
pop eax
|
||||||
|
mov esi, [_length]
|
||||||
|
sub esi, eax
|
||||||
|
jbe .error.free
|
||||||
|
|
||||||
|
mov eax, [edx + Image.Extended]
|
||||||
|
mov eax, [eax + bmp.Image.info.Compression]
|
||||||
cmp eax, bmp.BI_RGB
|
cmp eax, bmp.BI_RGB
|
||||||
jne @f
|
jne @f
|
||||||
stdcall ._.rgb
|
stdcall ._.rgb
|
||||||
jmp .decoded
|
jmp .decoded
|
||||||
@@: cmp eax, bmp.BI_RLE8
|
@@: cmp eax, bmp.BI_RLE8
|
||||||
jne @f
|
jne @f
|
||||||
|
cmp [ebx + bmp.Header.info.BitCount], 8
|
||||||
|
jnz .error.free
|
||||||
stdcall ._.rle
|
stdcall ._.rle
|
||||||
jmp .decoded
|
jmp .decoded
|
||||||
@@: cmp eax, bmp.BI_RLE4
|
@@: cmp eax, bmp.BI_RLE4
|
||||||
jne @f
|
jne @f
|
||||||
|
cmp [ebx + bmp.Header.info.BitCount], 4
|
||||||
|
jnz .error.free
|
||||||
stdcall ._.rle
|
stdcall ._.rle
|
||||||
jmp .decoded
|
jmp .decoded
|
||||||
@@: cmp eax, bmp.BI_BITFIELDS
|
@@: cmp eax, bmp.BI_BITFIELDS
|
||||||
jne @f
|
jne .error.free
|
||||||
stdcall ._.bitfields
|
stdcall ._.bitfields
|
||||||
jmp .decoded
|
jmp .decoded
|
||||||
@@: cmp eax, bmp.BI_JPEG
|
; BI_JPEG and BI_PNG constants are not valid values for BMP file,
|
||||||
jne @f
|
; they are intended for WinAPI
|
||||||
stdcall ._.jpeg
|
; @@: cmp eax, bmp.BI_JPEG
|
||||||
jmp .decoded
|
; jne @f
|
||||||
@@: cmp eax, bmp.BI_PNG
|
; stdcall ._.jpeg
|
||||||
jne .error
|
; jmp .decoded
|
||||||
stdcall ._.png
|
; @@: cmp eax, bmp.BI_PNG
|
||||||
|
; jne .error
|
||||||
|
; stdcall ._.png
|
||||||
|
|
||||||
.decoded:
|
.decoded:
|
||||||
or eax, eax
|
or eax, eax
|
||||||
jz @f
|
jz @f
|
||||||
|
.error.free:
|
||||||
stdcall img.destroy, [img]
|
stdcall img.destroy, [img]
|
||||||
jmp .error
|
jmp .error
|
||||||
|
|
||||||
@@: stdcall img.flip, [img], FLIP_VERTICAL
|
@@:
|
||||||
|
cmp [bTopDown], 0
|
||||||
|
jnz @f
|
||||||
|
stdcall img.flip, [img], FLIP_VERTICAL
|
||||||
|
@@:
|
||||||
mov eax, [img]
|
mov eax, [img]
|
||||||
|
pop edi esi ebx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
pop ebx
|
pop edi esi ebx
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
@ -175,7 +267,7 @@ proc img.decode.bmp._.rgb ;/////////////////////////////////////////////////////
|
|||||||
mov [ecx + bmp.Image.info.AlphaMask], 0
|
mov [ecx + bmp.Image.info.AlphaMask], 0
|
||||||
mov edi, [edx + Image.Data]
|
mov edi, [edx + Image.Data]
|
||||||
|
|
||||||
movzx eax, [ebx + bmp.Header.info.BitCount]
|
movzx eax, [ecx + bmp.Image.info.BitCount]
|
||||||
cmp eax, 32
|
cmp eax, 32
|
||||||
je .32bpp
|
je .32bpp
|
||||||
cmp eax, 24
|
cmp eax, 24
|
||||||
@ -202,13 +294,19 @@ img.decode.bmp._.rgb.32bpp:
|
|||||||
;;------------------------------------------------------------------------------------------------;;
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
|
|
||||||
img.decode.bmp._.rgb.24bpp:
|
img.decode.bmp._.rgb.24bpp:
|
||||||
|
mov eax, [edx + Image.Width]
|
||||||
|
lea eax, [eax*3 + 3]
|
||||||
|
and eax, not 3
|
||||||
|
mov ecx, [edx + Image.Height]
|
||||||
|
imul eax, ecx
|
||||||
|
cmp esi, eax
|
||||||
|
jb img.decode.bmp._.rgb.error
|
||||||
mov esi, ebx
|
mov esi, ebx
|
||||||
add esi, [ebx + bmp.Header.file.OffBits]
|
add esi, [ebx + bmp.Header.file.OffBits]
|
||||||
mov ecx, [ebx + bmp.Header.info.Height]
|
|
||||||
|
|
||||||
.next_line:
|
.next_line:
|
||||||
push ecx
|
push ecx edx
|
||||||
mov ecx, [ebx + bmp.Header.info.Width]
|
mov ecx, [edx + Image.Width]
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
|
|
||||||
.next_line_pixel:
|
.next_line_pixel:
|
||||||
@ -220,7 +318,7 @@ img.decode.bmp._.rgb.24bpp:
|
|||||||
|
|
||||||
and edx, 0x03
|
and edx, 0x03
|
||||||
add esi, edx
|
add esi, edx
|
||||||
pop ecx
|
pop edx ecx
|
||||||
dec ecx
|
dec ecx
|
||||||
jnz .next_line
|
jnz .next_line
|
||||||
|
|
||||||
@ -238,22 +336,19 @@ img.decode.bmp._.rgb.16bpp:
|
|||||||
;;------------------------------------------------------------------------------------------------;;
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
|
|
||||||
img.decode.bmp._.rgb.8bpp:
|
img.decode.bmp._.rgb.8bpp:
|
||||||
mov esi, ebx
|
mov eax, [edx + Image.Width]
|
||||||
add esi, [ebx + bmp.Header.file.OffBits]
|
add eax, 3
|
||||||
mov ecx, [ebx + bmp.Header.info.Height]
|
call img.decode.bmp._.rgb.prepare_palette
|
||||||
|
jc img.decode.bmp._.rgb.error
|
||||||
|
|
||||||
.next_line:
|
.next_line:
|
||||||
push ecx
|
push ecx
|
||||||
mov ecx, [ebx + bmp.Header.info.Width]
|
mov ecx, [edx + Image.Width]
|
||||||
|
mov eax, ecx
|
||||||
.next_line_dword:
|
neg eax
|
||||||
lodsb
|
and eax, 3
|
||||||
and eax, 0x000000FF
|
rep movsb
|
||||||
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette]
|
add esi, eax
|
||||||
stosd
|
|
||||||
dec ecx
|
|
||||||
jnz .next_line_dword
|
|
||||||
|
|
||||||
pop ecx
|
pop ecx
|
||||||
dec ecx
|
dec ecx
|
||||||
jnz .next_line
|
jnz .next_line
|
||||||
@ -263,13 +358,15 @@ img.decode.bmp._.rgb.8bpp:
|
|||||||
;;------------------------------------------------------------------------------------------------;;
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
|
|
||||||
img.decode.bmp._.rgb.4bpp:
|
img.decode.bmp._.rgb.4bpp:
|
||||||
mov esi, ebx
|
mov eax, [edx + Image.Width]
|
||||||
add esi, [ebx + bmp.Header.file.OffBits]
|
add eax, 7
|
||||||
mov ecx, [ebx + bmp.Header.info.Height]
|
shr eax, 1
|
||||||
|
call img.decode.bmp._.rgb.prepare_palette
|
||||||
|
jc img.decode.bmp._.rgb.error
|
||||||
|
|
||||||
.next_line:
|
.next_line:
|
||||||
push ecx
|
push ecx edx
|
||||||
mov ecx, [ebx + bmp.Header.info.Width]
|
mov ecx, [edx + Image.Width]
|
||||||
|
|
||||||
.next_line_dword:
|
.next_line_dword:
|
||||||
push ecx
|
push ecx
|
||||||
@ -281,9 +378,8 @@ img.decode.bmp._.rgb.4bpp:
|
|||||||
.next_pixel:
|
.next_pixel:
|
||||||
rol edx, 4
|
rol edx, 4
|
||||||
mov al, dl
|
mov al, dl
|
||||||
and eax, 0x0000000F
|
and al, 0x0000000F
|
||||||
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette]
|
stosb
|
||||||
stosd
|
|
||||||
dec dword[esp]
|
dec dword[esp]
|
||||||
jz @f
|
jz @f
|
||||||
dec ecx
|
dec ecx
|
||||||
@ -293,7 +389,7 @@ img.decode.bmp._.rgb.4bpp:
|
|||||||
or ecx, ecx
|
or ecx, ecx
|
||||||
jnz .next_line_dword
|
jnz .next_line_dword
|
||||||
|
|
||||||
pop ecx
|
pop edx ecx
|
||||||
dec ecx
|
dec ecx
|
||||||
jnz .next_line
|
jnz .next_line
|
||||||
|
|
||||||
@ -302,13 +398,15 @@ img.decode.bmp._.rgb.4bpp:
|
|||||||
;;------------------------------------------------------------------------------------------------;;
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
|
|
||||||
img.decode.bmp._.rgb.1bpp:
|
img.decode.bmp._.rgb.1bpp:
|
||||||
mov esi, ebx
|
mov eax, [edx + Image.Width]
|
||||||
add esi, [ebx + bmp.Header.file.OffBits]
|
add eax, 31
|
||||||
mov ecx, [ebx + bmp.Header.info.Height]
|
shr eax, 3
|
||||||
|
call img.decode.bmp._.rgb.prepare_palette
|
||||||
|
jc img.decode.bmp._.rgb.error
|
||||||
|
|
||||||
.next_line:
|
.next_line:
|
||||||
push ecx
|
push ecx edx
|
||||||
mov ecx, [ebx + bmp.Header.info.Width]
|
mov ecx, [edx + Image.Width]
|
||||||
|
|
||||||
.next_line_dword:
|
.next_line_dword:
|
||||||
push ecx
|
push ecx
|
||||||
@ -320,9 +418,8 @@ img.decode.bmp._.rgb.1bpp:
|
|||||||
.next_pixel:
|
.next_pixel:
|
||||||
rol edx, 1
|
rol edx, 1
|
||||||
mov al, dl
|
mov al, dl
|
||||||
and eax, 0x00000001
|
and al, 0x00000001
|
||||||
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette]
|
stosb
|
||||||
stosd
|
|
||||||
dec dword[esp]
|
dec dword[esp]
|
||||||
jz @f
|
jz @f
|
||||||
dec ecx
|
dec ecx
|
||||||
@ -332,7 +429,7 @@ img.decode.bmp._.rgb.1bpp:
|
|||||||
or ecx, ecx
|
or ecx, ecx
|
||||||
jnz .next_line_dword
|
jnz .next_line_dword
|
||||||
|
|
||||||
pop ecx
|
pop edx ecx
|
||||||
dec ecx
|
dec ecx
|
||||||
jnz .next_line
|
jnz .next_line
|
||||||
|
|
||||||
@ -347,6 +444,48 @@ img.decode.bmp._.rgb.1bpp:
|
|||||||
img.decode.bmp._.rgb.error:
|
img.decode.bmp._.rgb.error:
|
||||||
or eax, -1
|
or eax, -1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
img.decode.bmp._.rgb.prepare_palette:
|
||||||
|
and eax, not 3
|
||||||
|
mov ecx, [edx + Image.Height]
|
||||||
|
imul eax, ecx
|
||||||
|
cmp esi, 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 edi, [edx + Image.Palette]
|
||||||
|
push ecx
|
||||||
|
mov ecx, 256
|
||||||
|
cmp esi, sizeof.bmp.FileHeader + 12
|
||||||
|
jz .old
|
||||||
|
shr eax, 2
|
||||||
|
add esi, ebx
|
||||||
|
cmp ecx, eax
|
||||||
|
jb @f
|
||||||
|
mov ecx, eax
|
||||||
|
@@:
|
||||||
|
rep movsd
|
||||||
|
jmp .common
|
||||||
|
.old:
|
||||||
|
movsd
|
||||||
|
dec esi
|
||||||
|
sub eax, 3
|
||||||
|
jbe @f
|
||||||
|
sub ecx, 1
|
||||||
|
jnz .old
|
||||||
|
@@:
|
||||||
|
.common:
|
||||||
|
pop ecx
|
||||||
|
pop edi
|
||||||
|
mov esi, ebx
|
||||||
|
add esi, [ebx + bmp.Header.file.OffBits]
|
||||||
|
.ret:
|
||||||
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
@ -365,27 +504,35 @@ locals
|
|||||||
marker_y dd ?
|
marker_y dd ?
|
||||||
abs_mode_addr dd ?
|
abs_mode_addr dd ?
|
||||||
enc_mode_addr dd ?
|
enc_mode_addr dd ?
|
||||||
|
height dd ?
|
||||||
endl
|
endl
|
||||||
|
|
||||||
mov edi, [edx + Image.Data]
|
|
||||||
|
|
||||||
mov [abs_mode_addr], .absolute_mode.rle8
|
mov [abs_mode_addr], .absolute_mode.rle8
|
||||||
mov [enc_mode_addr], .encoded_mode.rle8
|
mov [enc_mode_addr], .encoded_mode.rle8
|
||||||
cmp [ebx + bmp.Header.info.Compression], bmp.BI_RLE4
|
cmp [ebx + bmp.Header.info.Compression], bmp.BI_RLE4
|
||||||
jne @f
|
jne @f
|
||||||
mov [abs_mode_addr], .absolute_mode.rle4
|
mov [abs_mode_addr], .absolute_mode.rle4
|
||||||
mov [enc_mode_addr], .encoded_mode.rle4
|
mov [enc_mode_addr], .encoded_mode.rle4
|
||||||
|
@@:
|
||||||
|
|
||||||
|
push esi
|
||||||
|
xor eax, eax ; do not check file size in .prepare_palette
|
||||||
|
call img.decode.bmp._.rgb.prepare_palette
|
||||||
|
pop ecx ; ecx = rest bytes in file
|
||||||
|
jc .error
|
||||||
|
|
||||||
@@: mov esi, ebx
|
|
||||||
add esi, [ebx + bmp.Header.file.OffBits]
|
|
||||||
mov eax, [edx + Image.Width]
|
mov eax, [edx + Image.Width]
|
||||||
shl eax, 2
|
|
||||||
mov [scanline_len], eax
|
mov [scanline_len], eax
|
||||||
|
mov eax, [edx + Image.Height]
|
||||||
|
mov [height], eax
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov [marker_x], eax
|
mov [marker_x], eax
|
||||||
mov [marker_y], eax
|
mov [marker_y], eax
|
||||||
|
mov edi, [edx + Image.Data]
|
||||||
|
|
||||||
.next_run:
|
.next_run:
|
||||||
|
sub ecx, 1
|
||||||
|
jc .eof
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
lodsb
|
lodsb
|
||||||
or al, al
|
or al, al
|
||||||
@ -393,6 +540,8 @@ endl
|
|||||||
jmp [enc_mode_addr]
|
jmp [enc_mode_addr]
|
||||||
|
|
||||||
.escape_mode:
|
.escape_mode:
|
||||||
|
sub ecx, 1
|
||||||
|
jc .eof
|
||||||
lodsb
|
lodsb
|
||||||
cmp al, 0
|
cmp al, 0
|
||||||
je .end_of_scanline
|
je .end_of_scanline
|
||||||
@ -403,29 +552,30 @@ endl
|
|||||||
jmp [abs_mode_addr]
|
jmp [abs_mode_addr]
|
||||||
|
|
||||||
.end_of_scanline: ; 0
|
.end_of_scanline: ; 0
|
||||||
mov eax, [marker_x]
|
sub edi, [marker_x]
|
||||||
shl eax, 2
|
add edi, [scanline_len]
|
||||||
neg eax
|
|
||||||
add eax, [scanline_len]
|
|
||||||
add edi, eax
|
|
||||||
mov [marker_x], 0
|
mov [marker_x], 0
|
||||||
inc [marker_y]
|
mov eax, [marker_y]
|
||||||
jmp .next_run
|
inc eax
|
||||||
|
mov [marker_y], eax
|
||||||
|
cmp eax, [height]
|
||||||
|
jb .next_run
|
||||||
|
jmp .exit
|
||||||
|
|
||||||
.offset_marker: ; 2: dx, dy
|
.offset_marker: ; 2: dx, dy
|
||||||
|
sub ecx, 2
|
||||||
|
jc .eof
|
||||||
lodsb
|
lodsb
|
||||||
mov edx, [marker_x]
|
mov edx, [marker_x]
|
||||||
add edx, eax
|
add edx, eax
|
||||||
cmp edx, [ebx + bmp.Header.info.Width]
|
cmp edx, [scanline_len]
|
||||||
jae .exit
|
jae .exit
|
||||||
mov [marker_x], edx
|
mov [marker_x], edx
|
||||||
shl eax, 2
|
|
||||||
add edi, eax
|
add edi, eax
|
||||||
lodsb
|
lodsb
|
||||||
and eax, 0x0FF
|
|
||||||
mov edx, [marker_y]
|
mov edx, [marker_y]
|
||||||
add edx, eax
|
add edx, eax
|
||||||
cmp edx, [ebx + bmp.Header.info.Height]
|
cmp edx, [height]
|
||||||
jae .exit
|
jae .exit
|
||||||
mov [marker_y], edx
|
mov [marker_y], edx
|
||||||
imul eax, [scanline_len]
|
imul eax, [scanline_len]
|
||||||
@ -433,90 +583,112 @@ endl
|
|||||||
jmp .next_run
|
jmp .next_run
|
||||||
|
|
||||||
.encoded_mode.rle8: ; N: b1 * N
|
.encoded_mode.rle8: ; N: b1 * N
|
||||||
mov edx, eax
|
call .fix_marker
|
||||||
|
sub ecx, 1
|
||||||
|
jc .eof
|
||||||
lodsb
|
lodsb
|
||||||
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette]
|
push ecx
|
||||||
@@: dec edx
|
mov ecx, edx
|
||||||
js .fix_marker
|
rep stosb
|
||||||
stosd
|
pop ecx
|
||||||
inc [marker_x]
|
jmp .check_eoi
|
||||||
jmp @b
|
|
||||||
|
|
||||||
.absolute_mode.rle8: ; N: b1 .. bN
|
.absolute_mode.rle8: ; N: b1 .. bN
|
||||||
mov edx, eax
|
call .fix_marker
|
||||||
push eax
|
cmp ecx, edx
|
||||||
@@: dec edx
|
jae @f
|
||||||
js @f
|
mov edx, ecx
|
||||||
lodsb
|
@@:
|
||||||
and eax, 0x0FF
|
push ecx
|
||||||
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette]
|
mov ecx, edx
|
||||||
stosd
|
rep movsb
|
||||||
inc [marker_x]
|
pop ecx
|
||||||
jmp @b
|
sub ecx, edx
|
||||||
@@: pop eax
|
jz .eof
|
||||||
test eax, 1
|
test edx, 1
|
||||||
jz .fix_marker
|
jz .check_eoi
|
||||||
|
sub ecx, 1
|
||||||
|
jc .eof
|
||||||
inc esi
|
inc esi
|
||||||
jmp .fix_marker
|
.check_eoi:
|
||||||
|
mov eax, [marker_y]
|
||||||
|
cmp eax, [height]
|
||||||
|
jb .next_run
|
||||||
|
jmp .exit
|
||||||
|
|
||||||
.encoded_mode.rle4: ; N: b1 * N
|
.encoded_mode.rle4: ; N: b1 * N
|
||||||
mov edx, eax
|
call .fix_marker
|
||||||
lodsb
|
sub ecx, 1
|
||||||
|
jc .eof
|
||||||
|
movzx eax, byte [esi]
|
||||||
|
inc esi
|
||||||
|
push ecx
|
||||||
mov ecx, eax
|
mov ecx, eax
|
||||||
|
and eax, 0xF
|
||||||
shr ecx, 4
|
shr ecx, 4
|
||||||
mov ecx, [ebx + ecx * 4 + bmp.Header.info.Palette]
|
@@:
|
||||||
and eax, 0x00F
|
|
||||||
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette]
|
|
||||||
@@: dec edx
|
|
||||||
js .fix_marker
|
|
||||||
test edx, 1
|
|
||||||
jz .odd
|
|
||||||
mov [edi], ecx
|
|
||||||
add edi, 4
|
|
||||||
inc [marker_x]
|
|
||||||
jmp @b
|
|
||||||
.odd:
|
|
||||||
stosd
|
|
||||||
inc [marker_x]
|
|
||||||
jmp @b
|
|
||||||
|
|
||||||
.absolute_mode.rle4: ; N: b1 .. bN
|
|
||||||
mov edx, eax
|
|
||||||
push eax
|
|
||||||
@@: dec edx
|
|
||||||
js @f
|
|
||||||
lodsb
|
|
||||||
and eax, 0x0FF
|
|
||||||
mov ecx, eax
|
|
||||||
shr eax, 4
|
|
||||||
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette]
|
|
||||||
stosd
|
|
||||||
inc [marker_x]
|
|
||||||
dec edx
|
dec edx
|
||||||
js @f
|
js @f
|
||||||
mov eax, ecx
|
mov [edi], cl
|
||||||
and eax, 0x00F
|
dec edx
|
||||||
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette]
|
js @f
|
||||||
stosd
|
mov [edi+1], al
|
||||||
inc [marker_x]
|
add edi, 2
|
||||||
jmp @b
|
jmp @b
|
||||||
@@: pop eax
|
@@:
|
||||||
|
pop ecx
|
||||||
|
jmp .check_eoi
|
||||||
|
|
||||||
|
.absolute_mode.rle4: ; N: b1 .. bN
|
||||||
|
call .fix_marker
|
||||||
|
lea eax, [edx+1]
|
||||||
|
shr eax, 1
|
||||||
|
cmp ecx, eax
|
||||||
|
jbe @f
|
||||||
|
lea edx, [ecx*2]
|
||||||
|
@@:
|
||||||
|
push ecx edx
|
||||||
|
@@: dec edx
|
||||||
|
js @f
|
||||||
|
lodsb
|
||||||
|
mov cl, al
|
||||||
|
shr al, 4
|
||||||
|
and cl, 0xF
|
||||||
|
stosb
|
||||||
|
dec edx
|
||||||
|
js @f
|
||||||
|
mov [edi], cl
|
||||||
|
inc edi
|
||||||
|
jmp @b
|
||||||
|
@@: pop eax ecx
|
||||||
and eax, 0x03
|
and eax, 0x03
|
||||||
jz .fix_marker
|
jp .check_eoi
|
||||||
cmp eax, 3
|
sub ecx, 1
|
||||||
je .fix_marker
|
jc .eof
|
||||||
inc esi
|
inc esi
|
||||||
jmp .fix_marker
|
jmp .check_eoi
|
||||||
|
|
||||||
.fix_marker:
|
.fix_marker:
|
||||||
mov eax, [marker_x]
|
mov edx, eax
|
||||||
@@: sub eax, [ebx + bmp.Header.info.Width]
|
add eax, [marker_x]
|
||||||
jle .next_run
|
|
||||||
mov [marker_x], eax
|
mov [marker_x], eax
|
||||||
inc [marker_y]
|
@@:
|
||||||
jmp @b
|
sub eax, [scanline_len]
|
||||||
|
jle @f
|
||||||
|
mov [marker_x], eax
|
||||||
|
push eax
|
||||||
|
mov eax, [marker_y]
|
||||||
|
inc eax
|
||||||
|
mov [marker_y], eax
|
||||||
|
cmp eax, [height]
|
||||||
|
pop eax
|
||||||
|
jb @b
|
||||||
|
sub edx, eax
|
||||||
|
@@:
|
||||||
|
retn
|
||||||
|
|
||||||
.exit:
|
.exit:
|
||||||
|
.eof:
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -542,8 +714,23 @@ locals
|
|||||||
delta dd ?
|
delta dd ?
|
||||||
endl
|
endl
|
||||||
|
|
||||||
push esi edi
|
push edi
|
||||||
mov esi, [edx + Image.Extended]
|
|
||||||
|
mov [delta], 4
|
||||||
|
mov eax, [edx + Image.Extended]
|
||||||
|
cmp [eax + bmp.Image.info.BitCount], 32
|
||||||
|
je @f
|
||||||
|
cmp [eax + bmp.Image.info.BitCount], 16
|
||||||
|
jne .error
|
||||||
|
mov [delta], 2
|
||||||
|
@@:
|
||||||
|
mov ecx, [edx + Image.Width]
|
||||||
|
imul ecx, [edx + Image.Height]
|
||||||
|
imul ecx, [delta]
|
||||||
|
cmp esi, ecx
|
||||||
|
jb .error
|
||||||
|
|
||||||
|
mov esi, eax
|
||||||
|
|
||||||
mov ecx, [esi + bmp.Image.info.RedMask]
|
mov ecx, [esi + bmp.Image.info.RedMask]
|
||||||
call .calc_shift
|
call .calc_shift
|
||||||
@ -577,17 +764,9 @@ endl
|
|||||||
mov esi, ebx
|
mov esi, ebx
|
||||||
add esi, [ebx + bmp.Header.file.OffBits]
|
add esi, [ebx + bmp.Header.file.OffBits]
|
||||||
|
|
||||||
mov [delta], 4
|
|
||||||
movzx eax, [ebx + bmp.Header.info.BitCount]
|
|
||||||
cmp eax, 32
|
|
||||||
je @f
|
|
||||||
cmp eax, 16
|
|
||||||
jne .error
|
|
||||||
mov [delta], 2
|
|
||||||
|
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
|
|
||||||
@@: mov ecx, [edx + Image.Height]
|
mov ecx, [edx + Image.Height]
|
||||||
|
|
||||||
.next_line:
|
.next_line:
|
||||||
push ecx
|
push ecx
|
||||||
@ -642,12 +821,12 @@ endl
|
|||||||
|
|
||||||
.exit:
|
.exit:
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
pop edi esi
|
pop edi
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
or eax, -1
|
or eax, -1
|
||||||
pop edi esi
|
pop edi
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.calc_shift:
|
.calc_shift:
|
||||||
@ -678,6 +857,7 @@ endl
|
|||||||
retn
|
retn
|
||||||
endp
|
endp
|
||||||
|
|
||||||
|
if 0
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
proc img.decode.bmp._.jpeg ;//////////////////////////////////////////////////////////////////////;;
|
proc img.decode.bmp._.jpeg ;//////////////////////////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
@ -705,7 +885,7 @@ proc img.decode.bmp._.png ;/////////////////////////////////////////////////////
|
|||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
end if
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
;;//// bmp.inc //// (c) mike.dld, 2007-2008 //////////////////////////////////////////////////////;;
|
;;//// bmp.inc //// (c) mike.dld, 2007-2008, (c) diamond, 2009 ///////////////////////////////////;;
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; 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 ;;
|
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
|
||||||
;; General Public License as published by the Free Software Foundation, either version 3 of the ;;
|
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
|
||||||
;; 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 ;;
|
;; 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 ;;
|
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
|
||||||
;; General Public License for more details. ;;
|
;; Lesser General Public License for more details. ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
|
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
|
||||||
;; see <http://www.gnu.org/licenses/>. ;;
|
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
|
|
||||||
@ -28,10 +28,20 @@ ends
|
|||||||
struct bmp.InfoHeader
|
struct bmp.InfoHeader
|
||||||
; v2 (Windows 2.x)
|
; v2 (Windows 2.x)
|
||||||
Size dd ? ; Size of this header in bytes
|
Size dd ? ; Size of this header in bytes
|
||||||
Width dd ? ; Image width in pixels
|
union
|
||||||
Height dd ? ; Image height in pixels
|
struct ; new format
|
||||||
Planes dw ? ; Number of color planes
|
Width dd ? ; Image width in pixels
|
||||||
BitCount dw ? ; Number of bits per pixel
|
Height dd ? ; Image height in pixels
|
||||||
|
Planes dw ? ; Number of color planes
|
||||||
|
BitCount dw ? ; Number of bits per pixel
|
||||||
|
ends
|
||||||
|
struct ; old format
|
||||||
|
OldWidth dw ? ; Image width in pixels as word
|
||||||
|
OldHeight dw ? ; Image height in pixels as word
|
||||||
|
OldPlanes dw ? ; Number of color planes
|
||||||
|
OldBitCount dw ? ; Number of bits per pixel
|
||||||
|
ends
|
||||||
|
ends
|
||||||
; v3 (Windows 3.x)
|
; v3 (Windows 3.x)
|
||||||
Compression dd ? ; Compression method used
|
Compression dd ? ; Compression method used
|
||||||
SizeImage dd ? ; Size of bitmap in bytes
|
SizeImage dd ? ; Size of bitmap in bytes
|
||||||
|
@ -5,15 +5,15 @@
|
|||||||
;; 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 ;;
|
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
|
||||||
;; General Public License as published by the Free Software Foundation, either version 3 of the ;;
|
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
|
||||||
;; 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 ;;
|
;; 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 ;;
|
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
|
||||||
;; General Public License for more details. ;;
|
;; Lesser General Public License for more details. ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
|
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
|
||||||
;; see <http://www.gnu.org/licenses/>. ;;
|
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
;; ;;
|
;; ;;
|
||||||
|
@ -7,15 +7,15 @@
|
|||||||
;; 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 ;;
|
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
|
||||||
;; General Public License as published by the Free Software Foundation, either version 3 of the ;;
|
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
|
||||||
;; 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 ;;
|
;; 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 ;;
|
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
|
||||||
;; General Public License for more details. ;;
|
;; Lesser General Public License for more details. ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
|
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
|
||||||
;; see <http://www.gnu.org/licenses/>. ;;
|
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
;; ;;
|
;; ;;
|
||||||
@ -84,20 +84,18 @@ proc img.decode.gif _data, _length ;////////////////////////////////////////////
|
|||||||
locals
|
locals
|
||||||
img dd ?
|
img dd ?
|
||||||
global_color_table dd ?
|
global_color_table dd ?
|
||||||
|
global_color_table_size dd ?
|
||||||
endl
|
endl
|
||||||
|
|
||||||
push ebx
|
push ebx
|
||||||
|
|
||||||
stdcall img.is.gif, [_data], [_length]
|
; img.is.gif is called by caller (img.decode)
|
||||||
or eax, eax
|
; stdcall img.is.gif, [_data], [_length]
|
||||||
jz .error
|
; or eax, eax
|
||||||
|
; jz .error
|
||||||
|
|
||||||
|
mov [global_color_table_size], 0
|
||||||
mov ebx, [_data]
|
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
|
|
||||||
|
|
||||||
test [ebx + gif.Header.lsd.Packed], gif.LSD.Packed.GlobalColorTableFlag
|
test [ebx + gif.Header.lsd.Packed], gif.LSD.Packed.GlobalColorTableFlag
|
||||||
jz @f
|
jz @f
|
||||||
@ -106,9 +104,9 @@ endl
|
|||||||
mov cl, [ebx + gif.Header.lsd.Packed]
|
mov cl, [ebx + gif.Header.lsd.Packed]
|
||||||
and cl, gif.LSD.Packed.SizeOfGlobalColorTableMask
|
and cl, gif.LSD.Packed.SizeOfGlobalColorTableMask
|
||||||
shr cl, gif.LSD.Packed.SizeOfGlobalColorTableShift
|
shr cl, gif.LSD.Packed.SizeOfGlobalColorTableShift
|
||||||
inc cl
|
mov eax, 2
|
||||||
mov eax, 1
|
|
||||||
shl eax, cl
|
shl eax, cl
|
||||||
|
mov [global_color_table_size], eax
|
||||||
lea eax, [eax * 3]
|
lea eax, [eax * 3]
|
||||||
add ebx, eax
|
add ebx, eax
|
||||||
@@: add ebx, sizeof.gif.Header
|
@@: add ebx, sizeof.gif.Header
|
||||||
@ -130,11 +128,15 @@ endl
|
|||||||
jz .error
|
jz .error
|
||||||
mov edx, [img]
|
mov edx, [img]
|
||||||
mov [eax + Image.Previous], edx
|
mov [eax + Image.Previous], edx
|
||||||
|
test edx, edx
|
||||||
|
jz @f
|
||||||
|
mov [edx + Image.Next], eax
|
||||||
|
@@:
|
||||||
mov [img], eax
|
mov [img], eax
|
||||||
mov edx, eax
|
mov edx, eax
|
||||||
|
mov [eax + Image.Type], Image.bpp8
|
||||||
|
|
||||||
mov ecx, sizeof.gif.Image
|
invoke mem.alloc, sizeof.gif.Image
|
||||||
invoke mem.alloc, ecx
|
|
||||||
or eax, eax
|
or eax, eax
|
||||||
jz .error
|
jz .error
|
||||||
mov [edx + Image.Extended], eax
|
mov [edx + Image.Extended], eax
|
||||||
@ -149,33 +151,34 @@ endl
|
|||||||
or eax, eax
|
or eax, eax
|
||||||
jz .error
|
jz .error
|
||||||
|
|
||||||
xor ecx, ecx
|
mov esi, ebx
|
||||||
mov eax, [edx + Image.Extended]
|
mov edi, [edx + Image.Extended]
|
||||||
|
mov ecx, sizeof.gif.ImageDescriptor
|
||||||
|
rep movsb
|
||||||
|
|
||||||
|
mov edi, [edx + Image.Palette]
|
||||||
|
mov esi, [global_color_table]
|
||||||
|
mov ecx, [global_color_table_size]
|
||||||
test [ebx + gif.ImageDescriptor.Packed], gif.ID.Packed.LocalColorTableFlag
|
test [ebx + gif.ImageDescriptor.Packed], gif.ID.Packed.LocalColorTableFlag
|
||||||
jz @f
|
jz @f
|
||||||
|
lea esi, [ebx + sizeof.gif.ImageDescriptor]
|
||||||
mov cl, [ebx + gif.ImageDescriptor.Packed]
|
mov cl, [ebx + gif.ImageDescriptor.Packed]
|
||||||
and cl, gif.ID.Packed.SizeOfLocalColorTableMask
|
and cl, gif.ID.Packed.SizeOfLocalColorTableMask
|
||||||
shr cl, gif.ID.Packed.SizeOfLocalColorTableShift
|
shr cl, gif.ID.Packed.SizeOfLocalColorTableShift
|
||||||
inc cl
|
mov eax, 2
|
||||||
mov eax, 1
|
|
||||||
shl eax, cl
|
shl eax, cl
|
||||||
lea ecx, [eax * sizeof.gif.RgbTriplet]
|
mov ecx, eax
|
||||||
lea eax, [ecx + sizeof.gif.Image]
|
lea eax, [eax*3]
|
||||||
invoke mem.realloc, [edx + Image.Extended], eax
|
add ebx, eax
|
||||||
or eax, eax
|
@@:
|
||||||
jz .error
|
lodsd
|
||||||
mov [edx + Image.Extended], eax
|
dec esi
|
||||||
@@: mov esi, ebx
|
bswap eax
|
||||||
lea edi, [eax + sizeof.gif.GraphicsControlExtension]
|
shr eax, 8
|
||||||
add ecx, sizeof.gif.ImageDescriptor
|
stosd
|
||||||
rep movsb
|
loop @b
|
||||||
|
add ebx, sizeof.gif.ImageDescriptor
|
||||||
mov eax, [global_color_table]
|
stdcall ._.process_image
|
||||||
test [ebx + gif.ImageDescriptor.Packed], gif.ID.Packed.LocalColorTableFlag
|
|
||||||
jz @f
|
|
||||||
lea eax, [ebx + sizeof.gif.ImageDescriptor]
|
|
||||||
@@: mov ebx, esi
|
|
||||||
stdcall ._.process_image, eax
|
|
||||||
|
|
||||||
.decoded:
|
.decoded:
|
||||||
or eax, eax
|
or eax, eax
|
||||||
@ -187,6 +190,11 @@ endl
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
|
mov eax, [img]
|
||||||
|
test eax, eax
|
||||||
|
jz @f
|
||||||
|
stdcall img.destroy, eax
|
||||||
|
@@:
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
pop ebx
|
pop ebx
|
||||||
ret
|
ret
|
||||||
@ -309,7 +317,7 @@ proc img.decode.gif._.process_extensions ;//////////////////////////////////////
|
|||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
proc img.decode.gif._.process_image _color_table ;////////////////////////////////////////////////;;
|
proc img.decode.gif._.process_image ;/////////////////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
;? --- TBD --- ;;
|
;? --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
@ -342,8 +350,6 @@ endl
|
|||||||
mov [width], ecx
|
mov [width], ecx
|
||||||
mov eax, [edx + Image.Height]
|
mov eax, [edx + Image.Height]
|
||||||
imul eax, ecx
|
imul eax, ecx
|
||||||
; lea eax, [eax * 3]
|
|
||||||
shl eax, 2
|
|
||||||
mov [img_end], eax
|
mov [img_end], eax
|
||||||
inc eax
|
inc eax
|
||||||
mov [row_end], eax
|
mov [row_end], eax
|
||||||
@ -351,8 +357,6 @@ endl
|
|||||||
mov eax, [edx + Image.Extended]
|
mov eax, [edx + Image.Extended]
|
||||||
test [eax + gif.Image.info.Packed], gif.ID.Packed.InterleaceFlag
|
test [eax + gif.Image.info.Packed], gif.ID.Packed.InterleaceFlag
|
||||||
jz @f
|
jz @f
|
||||||
; lea ecx, [ecx * 3]
|
|
||||||
shl ecx, 2
|
|
||||||
mov [row_end], ecx
|
mov [row_end], ecx
|
||||||
|
|
||||||
@@: mov esi, ebx
|
@@: mov esi, ebx
|
||||||
@ -502,21 +506,11 @@ img.decode.gif._.process_image.output:
|
|||||||
|
|
||||||
.loop2:
|
.loop2:
|
||||||
pop ax
|
pop ax
|
||||||
|
stosb
|
||||||
lea esi, [eax * 3]
|
|
||||||
add esi, [_color_table]
|
|
||||||
|
|
||||||
mov esi, [esi]
|
|
||||||
bswap esi
|
|
||||||
shr esi, 8
|
|
||||||
mov [edi], esi
|
|
||||||
add edi, 4
|
|
||||||
|
|
||||||
cmp edi, [row_end]
|
cmp edi, [row_end]
|
||||||
jb .norowend
|
jb .norowend
|
||||||
mov eax, [width]
|
mov eax, [width]
|
||||||
; lea eax, [eax * 3]
|
|
||||||
shl eax, 2
|
|
||||||
push eax
|
push eax
|
||||||
sub edi, eax
|
sub edi, eax
|
||||||
add eax, eax
|
add eax, eax
|
||||||
|
@ -5,15 +5,15 @@
|
|||||||
;; 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 ;;
|
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
|
||||||
;; General Public License as published by the Free Software Foundation, either version 3 of the ;;
|
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
|
||||||
;; 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 ;;
|
;; 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 ;;
|
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
|
||||||
;; General Public License for more details. ;;
|
;; Lesser General Public License for more details. ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
|
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
|
||||||
;; see <http://www.gnu.org/licenses/>. ;;
|
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
|
|
||||||
|
2231
programs/develop/libraries/libs-dev/libimg/jpeg/jpeg.asm
Normal file
2231
programs/develop/libraries/libs-dev/libimg/jpeg/jpeg.asm
Normal file
File diff suppressed because it is too large
Load Diff
96
programs/develop/libraries/libs-dev/libimg/jpeg/jpeg.inc
Normal file
96
programs/develop/libraries/libs-dev/libimg/jpeg/jpeg.inc
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
;;================================================================================================;;
|
||||||
|
;;//// jpeg.inc //// (c) diamond, 2008-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/>. ;;
|
||||||
|
;; ;;
|
||||||
|
;;================================================================================================;;
|
||||||
|
|
||||||
|
struct jpeg.work ; working area for JPEG handling
|
||||||
|
image dd ?
|
||||||
|
; progressive JPEG?
|
||||||
|
progressive db ?
|
||||||
|
; one component in the scan?
|
||||||
|
not_interleaved db ?
|
||||||
|
; Adobe YCCK file?
|
||||||
|
adobe_ycck db ?
|
||||||
|
rb 1
|
||||||
|
; parameters for progressive scan
|
||||||
|
ScanStart db ?
|
||||||
|
ScanEnd db ?
|
||||||
|
ApproxPosLow db ?
|
||||||
|
ApproxPosHigh db ?
|
||||||
|
; restart interval
|
||||||
|
restart_interval dd ?
|
||||||
|
decoded_MCUs dd ?
|
||||||
|
|
||||||
|
_esp dd ?
|
||||||
|
|
||||||
|
; components information, up to 4 components
|
||||||
|
; db ComponentIdentifier, db V, db H, db VFactor, db HFactor, db QuantizationTable
|
||||||
|
components rb 4*6
|
||||||
|
max_v db ?
|
||||||
|
max_h db ?
|
||||||
|
cur_rst_marker db ?
|
||||||
|
db ?
|
||||||
|
huffman_bits dd ?
|
||||||
|
block_width dd ?
|
||||||
|
block_height dd ?
|
||||||
|
block_delta_x dd ?
|
||||||
|
block_delta_y dd ?
|
||||||
|
cur_block_dx dd ?
|
||||||
|
cur_block_dy dd ?
|
||||||
|
x_num_blocks dd ?
|
||||||
|
y_num_blocks dd ?
|
||||||
|
delta_x dd ?
|
||||||
|
delta_y dd ?
|
||||||
|
pixel_size dd ?
|
||||||
|
line_size dd ?
|
||||||
|
cur_x dd ?
|
||||||
|
cur_y dd ?
|
||||||
|
max_x dd ?
|
||||||
|
max_y dd ?
|
||||||
|
cur_out_ptr dd ?
|
||||||
|
dct_buffer dd ?
|
||||||
|
dct_buffer_size dd ?
|
||||||
|
;ns dd ?
|
||||||
|
; +0: db V, db H, db VFactor, db HFactor, dd HIncrement, dd VIncrement,
|
||||||
|
; +12: dd QuantizationTable, dd DCTable, dd ACTable,
|
||||||
|
; +24: dd width/HFactor, dd width/HFactor-8k, dd HFactor+1-(width%HFactor),
|
||||||
|
; +36: dd height/VFactor, dd height/VFactor-8m, dd VFactor+1-(height%VFactor),
|
||||||
|
; +48: dw DCPrediction, db ?, db (0 for Y, 80h for Cb,Cr), dd ComponentOffset
|
||||||
|
cur_components rb 4*56
|
||||||
|
cur_components_end dd ?
|
||||||
|
; Fourier coefficients
|
||||||
|
dct_coeff rw 64
|
||||||
|
; Temporary space for IDCT
|
||||||
|
idct_tmp_area rd 64
|
||||||
|
; decoded block 8*8
|
||||||
|
decoded_data rb 8*8
|
||||||
|
; up to 4 quantization tables
|
||||||
|
quant_tables rd 4*64
|
||||||
|
quant_tables_defined rb 4
|
||||||
|
|
||||||
|
; Huffman tables
|
||||||
|
dc_huffman_defined rb 4
|
||||||
|
ac_huffman_defined rb 4
|
||||||
|
; up to 4 DC Huffman tables
|
||||||
|
;dc_huffman rd 4*256*2
|
||||||
|
; up to 4 AC Huffman tables
|
||||||
|
;ac_huffman rd 4*256*2
|
||||||
|
max_hufftable_size = (256 + (9+128)*16)*2
|
||||||
|
dc_huffman rb 4*max_hufftable_size
|
||||||
|
ac_huffman rb 4*max_hufftable_size
|
||||||
|
|
||||||
|
ends
|
@ -1,19 +1,19 @@
|
|||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
;;//// libimg.asm //// (c) mike.dld, 2007-2008 ///////////////////////////////////////////////////;;
|
;;//// libimg.asm //// (c) mike.dld, 2007-2008, (c) diamond, 2009 ////////////////////////////////;;
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; 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 ;;
|
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
|
||||||
;; General Public License as published by the Free Software Foundation, either version 3 of the ;;
|
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
|
||||||
;; 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 ;;
|
;; 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 ;;
|
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
|
||||||
;; General Public License for more details. ;;
|
;; Lesser General Public License for more details. ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
|
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
|
||||||
;; see <http://www.gnu.org/licenses/>. ;;
|
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ public @EXPORT as 'EXPORTS'
|
|||||||
include '../../../../struct.inc'
|
include '../../../../struct.inc'
|
||||||
include '../../../../proc32.inc'
|
include '../../../../proc32.inc'
|
||||||
include '../../../../macros.inc'
|
include '../../../../macros.inc'
|
||||||
purge section,mov;add,sub
|
purge section,mov,add,sub
|
||||||
|
|
||||||
include 'libimg.inc'
|
include 'libimg.inc'
|
||||||
|
|
||||||
@ -33,6 +33,7 @@ section '.flat' code readable align 16
|
|||||||
|
|
||||||
include 'bmp/bmp.asm'
|
include 'bmp/bmp.asm'
|
||||||
include 'gif/gif.asm'
|
include 'gif/gif.asm'
|
||||||
|
include 'jpeg/jpeg.asm'
|
||||||
|
|
||||||
mem.alloc dd ?
|
mem.alloc dd ?
|
||||||
mem.free dd ?
|
mem.free dd ?
|
||||||
@ -56,6 +57,8 @@ proc lib_init ;/////////////////////////////////////////////////////////////////
|
|||||||
mov [mem.realloc], ecx
|
mov [mem.realloc], ecx
|
||||||
mov [dll.load], edx
|
mov [dll.load], edx
|
||||||
|
|
||||||
|
call img.initialize.jpeg
|
||||||
|
|
||||||
.ok: xor eax,eax
|
.ok: xor eax,eax
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
@ -162,6 +165,14 @@ proc img.to_rgb _img ;//////////////////////////////////////////////////////////
|
|||||||
stosd
|
stosd
|
||||||
mov eax, [esi + Image.Height]
|
mov eax, [esi + Image.Height]
|
||||||
stosd
|
stosd
|
||||||
|
mov eax, [esi + Image.Type]
|
||||||
|
dec eax
|
||||||
|
jz .bpp8
|
||||||
|
dec eax
|
||||||
|
jz .bpp24
|
||||||
|
dec eax
|
||||||
|
jnz .error_pop
|
||||||
|
; 32 BPP -> 24 BPP
|
||||||
mov esi, [esi + Image.Data]
|
mov esi, [esi + Image.Data]
|
||||||
|
|
||||||
@@: dec ecx
|
@@: dec ecx
|
||||||
@ -174,6 +185,37 @@ proc img.to_rgb _img ;//////////////////////////////////////////////////////////
|
|||||||
pop edi esi
|
pop edi esi
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
.bpp24:
|
||||||
|
; 24 BPP -> 24 BPP
|
||||||
|
lea ecx, [ecx*3 + 3]
|
||||||
|
mov esi, [esi + Image.Data]
|
||||||
|
shr ecx, 2
|
||||||
|
rep movsd
|
||||||
|
pop eax
|
||||||
|
pop edi esi
|
||||||
|
ret
|
||||||
|
|
||||||
|
.bpp8:
|
||||||
|
; 8 BPP -> 24 BPP
|
||||||
|
push ebx
|
||||||
|
mov ebx, [esi + Image.Palette]
|
||||||
|
mov esi, [esi + Image.Data]
|
||||||
|
@@:
|
||||||
|
movzx eax, byte [esi]
|
||||||
|
add esi, 1
|
||||||
|
mov eax, [ebx + eax*4]
|
||||||
|
mov [edi], eax
|
||||||
|
add edi, 3
|
||||||
|
sub ecx, 1
|
||||||
|
jnz @b
|
||||||
|
pop ebx
|
||||||
|
pop eax
|
||||||
|
pop edi esi
|
||||||
|
ret
|
||||||
|
|
||||||
|
.error_pop:
|
||||||
|
pop eax
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
pop edi esi
|
pop edi esi
|
||||||
@ -196,7 +238,7 @@ proc img.decode _data, _length ;////////////////////////////////////////////////
|
|||||||
jnz @f
|
jnz @f
|
||||||
add ebx, sizeof.FormatsTableEntry
|
add ebx, sizeof.FormatsTableEntry
|
||||||
cmp dword[ebx], 0
|
cmp dword[ebx], 0
|
||||||
jnz @f
|
jnz @b
|
||||||
jmp .error
|
jmp .error
|
||||||
@@: stdcall [ebx + FormatsTableEntry.Decode], [_data], [_length]
|
@@: stdcall [ebx + FormatsTableEntry.Decode], [_data], [_length]
|
||||||
|
|
||||||
@ -219,7 +261,7 @@ proc img.encode _img, _p_length ;///////////////////////////////////////////////
|
|||||||
endp
|
endp
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
proc img.create _width, _height ;/////////////////////////////////////////////////////////////////;;
|
proc img.create _width, _height, _type ;//////////////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
;? --- TBD --- ;;
|
;? --- TBD --- ;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
@ -233,6 +275,9 @@ proc img.create _width, _height ;///////////////////////////////////////////////
|
|||||||
or eax, eax
|
or eax, eax
|
||||||
jz .error
|
jz .error
|
||||||
|
|
||||||
|
mov ecx, [_type]
|
||||||
|
mov [eax + Image.Type], ecx
|
||||||
|
|
||||||
push eax
|
push eax
|
||||||
|
|
||||||
stdcall img._.resize_data, eax, [_width], [_height]
|
stdcall img._.resize_data, eax, [_width], [_height]
|
||||||
@ -240,7 +285,7 @@ proc img.create _width, _height ;///////////////////////////////////////////////
|
|||||||
jz .error.2
|
jz .error.2
|
||||||
|
|
||||||
pop eax
|
pop eax
|
||||||
ret
|
jmp .ret
|
||||||
|
|
||||||
.error.2:
|
.error.2:
|
||||||
; pop eax
|
; pop eax
|
||||||
@ -248,6 +293,7 @@ proc img.create _width, _height ;///////////////////////////////////////////////
|
|||||||
xor eax, eax
|
xor eax, eax
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
|
.ret:
|
||||||
pop ecx
|
pop ecx
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
@ -348,39 +394,51 @@ locals
|
|||||||
scanline_len dd ?
|
scanline_len dd ?
|
||||||
endl
|
endl
|
||||||
|
|
||||||
push esi edi
|
push ebx esi edi
|
||||||
stdcall img._.validate, [_img]
|
mov ebx, [_img]
|
||||||
|
stdcall img._.validate, ebx
|
||||||
or eax, eax
|
or eax, eax
|
||||||
jnz .error
|
jnz .error
|
||||||
|
|
||||||
mov esi, [_img]
|
mov ecx, [ebx + Image.Height]
|
||||||
mov ecx, [esi + Image.Height]
|
mov eax, [ebx + Image.Width]
|
||||||
mov eax, [esi + Image.Width]
|
call img._.get_scanline_len
|
||||||
shl eax, 2
|
|
||||||
mov [scanline_len], eax
|
mov [scanline_len], eax
|
||||||
|
|
||||||
push esi
|
|
||||||
|
|
||||||
test [_flip_kind], FLIP_VERTICAL
|
test [_flip_kind], FLIP_VERTICAL
|
||||||
jz .dont_flip_vert
|
jz .dont_flip_vert
|
||||||
|
|
||||||
imul eax, ecx
|
imul eax, ecx
|
||||||
sub eax, [scanline_len]
|
sub eax, [scanline_len]
|
||||||
shr ecx, 1
|
shr ecx, 1
|
||||||
mov esi, [esi + Image.Data]
|
mov esi, [ebx + Image.Data]
|
||||||
lea edi, [esi + eax]
|
lea edi, [esi + eax]
|
||||||
|
|
||||||
.next_line_vert:
|
.next_line_vert:
|
||||||
push ecx
|
push ecx
|
||||||
|
|
||||||
mov ecx, [scanline_len]
|
mov ecx, [scanline_len]
|
||||||
|
push ecx
|
||||||
shr ecx, 2
|
shr ecx, 2
|
||||||
@@: lodsd
|
@@: mov eax, [esi]
|
||||||
xchg eax, [edi]
|
xchg eax, [edi]
|
||||||
mov [esi - 4], eax
|
mov [esi], eax
|
||||||
|
add esi, 4
|
||||||
add edi, 4
|
add edi, 4
|
||||||
|
sub ecx, 1
|
||||||
|
jnz @b
|
||||||
|
pop ecx
|
||||||
|
and ecx, 3
|
||||||
|
jz .cont_line_vert
|
||||||
|
@@:
|
||||||
|
mov al, [esi]
|
||||||
|
xchg al, [edi]
|
||||||
|
mov [esi], al
|
||||||
|
add esi, 1
|
||||||
|
add edi, 1
|
||||||
dec ecx
|
dec ecx
|
||||||
jnz @b
|
jnz @b
|
||||||
|
.cont_line_vert:
|
||||||
|
|
||||||
pop ecx
|
pop ecx
|
||||||
mov eax, [scanline_len]
|
mov eax, [scanline_len]
|
||||||
@ -391,15 +449,21 @@ endl
|
|||||||
|
|
||||||
.dont_flip_vert:
|
.dont_flip_vert:
|
||||||
|
|
||||||
pop esi
|
|
||||||
|
|
||||||
test [_flip_kind], FLIP_HORIZONTAL
|
test [_flip_kind], FLIP_HORIZONTAL
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
mov ecx, [esi + Image.Height]
|
mov ecx, [ebx + Image.Height]
|
||||||
mov esi, [esi + Image.Data]
|
mov eax, [ebx + Image.Type]
|
||||||
lea edi, [esi - 4]
|
mov esi, [ebx + Image.Data]
|
||||||
add edi, [scanline_len]
|
mov edi, [scanline_len]
|
||||||
|
add edi, esi
|
||||||
|
|
||||||
|
dec eax
|
||||||
|
jz .bpp8.2
|
||||||
|
dec eax
|
||||||
|
jz .bpp24.2
|
||||||
|
|
||||||
|
sub edi, 4
|
||||||
|
|
||||||
.next_line_horz:
|
.next_line_horz:
|
||||||
push ecx esi edi
|
push ecx esi edi
|
||||||
@ -411,7 +475,7 @@ endl
|
|||||||
mov [esi], eax
|
mov [esi], eax
|
||||||
add esi, 4
|
add esi, 4
|
||||||
add edi, -4
|
add edi, -4
|
||||||
dec ecx
|
sub ecx, 1
|
||||||
jnz @b
|
jnz @b
|
||||||
|
|
||||||
pop edi esi ecx
|
pop edi esi ecx
|
||||||
@ -419,16 +483,71 @@ endl
|
|||||||
add edi, [scanline_len]
|
add edi, [scanline_len]
|
||||||
dec ecx
|
dec ecx
|
||||||
jnz .next_line_horz
|
jnz .next_line_horz
|
||||||
|
jmp .exit
|
||||||
|
|
||||||
|
.bpp8.2:
|
||||||
|
dec edi
|
||||||
|
.next_line_horz8:
|
||||||
|
push ecx esi edi
|
||||||
|
|
||||||
|
mov ecx, [scanline_len]
|
||||||
|
shr ecx, 1
|
||||||
|
@@: mov al, [esi]
|
||||||
|
mov dl, [edi]
|
||||||
|
mov [edi], al
|
||||||
|
mov [esi], dl
|
||||||
|
add esi, 1
|
||||||
|
sub edi, 1
|
||||||
|
sub ecx, 1
|
||||||
|
jnz @b
|
||||||
|
|
||||||
|
pop edi esi ecx
|
||||||
|
add esi, [scanline_len]
|
||||||
|
add edi, [scanline_len]
|
||||||
|
dec ecx
|
||||||
|
jnz .next_line_horz8
|
||||||
|
jmp .exit
|
||||||
|
|
||||||
|
.bpp24.2:
|
||||||
|
sub edi, 3
|
||||||
|
.next_line_horz32:
|
||||||
|
push ecx esi edi
|
||||||
|
|
||||||
|
mov ecx, [ebx + Image.Width]
|
||||||
|
shr ecx, 1
|
||||||
|
@@:
|
||||||
|
mov al, [esi]
|
||||||
|
mov dl, [edi]
|
||||||
|
mov [edi], al
|
||||||
|
mov [esi], dl
|
||||||
|
mov al, [esi+1]
|
||||||
|
mov dl, [edi+1]
|
||||||
|
mov [edi+1], al
|
||||||
|
mov [esi+1], dl
|
||||||
|
mov al, [esi+2]
|
||||||
|
mov dl, [edi+2]
|
||||||
|
mov [edi+2], al
|
||||||
|
mov [esi+2], dl
|
||||||
|
add esi, 3
|
||||||
|
sub edi, 3
|
||||||
|
sub ecx, 1
|
||||||
|
jnz @b
|
||||||
|
|
||||||
|
pop edi esi ecx
|
||||||
|
add esi, [scanline_len]
|
||||||
|
add edi, [scanline_len]
|
||||||
|
dec ecx
|
||||||
|
jnz .next_line_horz32
|
||||||
|
|
||||||
.exit:
|
.exit:
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
inc eax
|
inc eax
|
||||||
pop edi esi
|
pop edi esi ebx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
pop edi esi
|
pop edi esi ebx
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
@ -453,7 +572,8 @@ endl
|
|||||||
mov [line_buffer], 0
|
mov [line_buffer], 0
|
||||||
|
|
||||||
push ebx esi edi
|
push ebx esi edi
|
||||||
stdcall img._.validate, [_img]
|
mov ebx, [_img]
|
||||||
|
stdcall img._.validate, ebx
|
||||||
or eax, eax
|
or eax, eax
|
||||||
jnz .error
|
jnz .error
|
||||||
|
|
||||||
@ -466,10 +586,9 @@ endl
|
|||||||
jmp .exit
|
jmp .exit
|
||||||
|
|
||||||
.rotate_ccw_low:
|
.rotate_ccw_low:
|
||||||
mov ebx, [_img]
|
|
||||||
mov eax, [ebx + Image.Height]
|
mov eax, [ebx + Image.Height]
|
||||||
mov [scanline_pixels_new], eax
|
mov [scanline_pixels_new], eax
|
||||||
shl eax, 2
|
call img._.get_scanline_len
|
||||||
mov [scanline_len_new], eax
|
mov [scanline_len_new], eax
|
||||||
|
|
||||||
invoke mem.alloc, eax
|
invoke mem.alloc, eax
|
||||||
@ -477,8 +596,9 @@ endl
|
|||||||
jz .error
|
jz .error
|
||||||
mov [line_buffer], eax
|
mov [line_buffer], eax
|
||||||
|
|
||||||
mov ecx, [ebx + Image.Width]
|
mov eax, [ebx + Image.Width]
|
||||||
lea eax, [ecx * 4]
|
mov ecx, eax
|
||||||
|
call img._.get_scanline_len
|
||||||
mov [scanline_len_old], eax
|
mov [scanline_len_old], eax
|
||||||
|
|
||||||
mov eax, [scanline_len_new]
|
mov eax, [scanline_len_new]
|
||||||
@ -486,9 +606,14 @@ endl
|
|||||||
add eax, [ebx + Image.Data]
|
add eax, [ebx + Image.Data]
|
||||||
mov [pixels_ptr], eax
|
mov [pixels_ptr], eax
|
||||||
|
|
||||||
|
cmp [ebx + Image.Type], Image.bpp8
|
||||||
|
jz .rotate_ccw8
|
||||||
|
cmp [ebx + Image.Type], Image.bpp24
|
||||||
|
jz .rotate_ccw24
|
||||||
|
|
||||||
.next_column_ccw_low:
|
.next_column_ccw_low:
|
||||||
dec ecx
|
dec ecx
|
||||||
jz .exchange_dims
|
js .exchange_dims
|
||||||
push ecx
|
push ecx
|
||||||
|
|
||||||
mov edx, [scanline_len_old]
|
mov edx, [scanline_len_old]
|
||||||
@ -524,11 +649,109 @@ endl
|
|||||||
pop ecx
|
pop ecx
|
||||||
jmp .next_column_ccw_low
|
jmp .next_column_ccw_low
|
||||||
|
|
||||||
|
.rotate_ccw8:
|
||||||
|
.next_column_ccw_low8:
|
||||||
|
dec ecx
|
||||||
|
js .exchange_dims
|
||||||
|
push ecx
|
||||||
|
|
||||||
|
mov edx, [scanline_len_old]
|
||||||
|
add [scanline_len_old], -1
|
||||||
|
|
||||||
|
mov ecx, [scanline_pixels_new]
|
||||||
|
mov esi, [ebx + Image.Data]
|
||||||
|
mov edi, [line_buffer]
|
||||||
|
@@: mov al, [esi]
|
||||||
|
mov [edi], al
|
||||||
|
add esi, edx
|
||||||
|
add edi, 1
|
||||||
|
sub ecx, 1
|
||||||
|
jnz @b
|
||||||
|
|
||||||
|
mov eax, [scanline_pixels_new]
|
||||||
|
mov edi, [ebx + Image.Data]
|
||||||
|
lea esi, [edi + 1]
|
||||||
|
mov edx, [scanline_len_old]
|
||||||
|
@@: mov ecx, edx
|
||||||
|
shr ecx, 2
|
||||||
|
rep movsd
|
||||||
|
mov ecx, edx
|
||||||
|
and ecx, 3
|
||||||
|
rep movsb
|
||||||
|
add esi, 1
|
||||||
|
sub eax, 1
|
||||||
|
jnz @b
|
||||||
|
|
||||||
|
mov eax, [scanline_len_new]
|
||||||
|
sub [pixels_ptr], eax
|
||||||
|
mov ecx, [scanline_pixels_new]
|
||||||
|
mov esi, [line_buffer]
|
||||||
|
mov edi, [pixels_ptr]
|
||||||
|
mov edx, ecx
|
||||||
|
shr ecx, 2
|
||||||
|
rep movsd
|
||||||
|
mov ecx, edx
|
||||||
|
and ecx, 3
|
||||||
|
rep movsb
|
||||||
|
|
||||||
|
pop ecx
|
||||||
|
jmp .next_column_ccw_low8
|
||||||
|
|
||||||
|
.rotate_ccw24:
|
||||||
|
.next_column_ccw_low24:
|
||||||
|
dec ecx
|
||||||
|
js .exchange_dims
|
||||||
|
push ecx
|
||||||
|
|
||||||
|
mov edx, [scanline_len_old]
|
||||||
|
add [scanline_len_old], -3
|
||||||
|
|
||||||
|
mov ecx, [scanline_pixels_new]
|
||||||
|
mov esi, [ebx + Image.Data]
|
||||||
|
mov edi, [line_buffer]
|
||||||
|
@@: mov al, [esi]
|
||||||
|
mov [edi], al
|
||||||
|
mov al, [esi+1]
|
||||||
|
mov [edi+1], al
|
||||||
|
mov al, [esi+2]
|
||||||
|
mov [edi+2], al
|
||||||
|
add esi, edx
|
||||||
|
add edi, 3
|
||||||
|
sub ecx, 1
|
||||||
|
jnz @b
|
||||||
|
|
||||||
|
mov eax, [scanline_pixels_new]
|
||||||
|
mov edi, [ebx + Image.Data]
|
||||||
|
lea esi, [edi + 3]
|
||||||
|
mov edx, [scanline_len_old]
|
||||||
|
@@: mov ecx, edx
|
||||||
|
shr ecx, 2
|
||||||
|
rep movsd
|
||||||
|
mov ecx, edx
|
||||||
|
and ecx, 3
|
||||||
|
rep movsb
|
||||||
|
add esi, 3
|
||||||
|
sub eax, 1
|
||||||
|
jnz @b
|
||||||
|
|
||||||
|
mov eax, [scanline_len_new]
|
||||||
|
sub [pixels_ptr], eax
|
||||||
|
mov ecx, eax
|
||||||
|
mov esi, [line_buffer]
|
||||||
|
mov edi, [pixels_ptr]
|
||||||
|
shr ecx, 2
|
||||||
|
rep movsd
|
||||||
|
mov ecx, eax
|
||||||
|
and ecx, 3
|
||||||
|
rep movsb
|
||||||
|
|
||||||
|
pop ecx
|
||||||
|
jmp .next_column_ccw_low24
|
||||||
|
|
||||||
.rotate_cw_low:
|
.rotate_cw_low:
|
||||||
mov ebx, [_img]
|
|
||||||
mov eax, [ebx + Image.Height]
|
mov eax, [ebx + Image.Height]
|
||||||
mov [scanline_pixels_new], eax
|
mov [scanline_pixels_new], eax
|
||||||
shl eax, 2
|
call img._.get_scanline_len
|
||||||
mov [scanline_len_new], eax
|
mov [scanline_len_new], eax
|
||||||
|
|
||||||
invoke mem.alloc, eax
|
invoke mem.alloc, eax
|
||||||
@ -536,8 +759,9 @@ endl
|
|||||||
jz .error
|
jz .error
|
||||||
mov [line_buffer], eax
|
mov [line_buffer], eax
|
||||||
|
|
||||||
mov ecx, [ebx + Image.Width]
|
mov eax, [ebx + Image.Width]
|
||||||
lea eax, [ecx * 4]
|
mov ecx, eax
|
||||||
|
call img._.get_scanline_len
|
||||||
mov [scanline_len_old], eax
|
mov [scanline_len_old], eax
|
||||||
|
|
||||||
mov eax, [scanline_len_new]
|
mov eax, [scanline_len_new]
|
||||||
@ -545,6 +769,11 @@ endl
|
|||||||
add eax, [ebx + Image.Data]
|
add eax, [ebx + Image.Data]
|
||||||
mov [pixels_ptr], eax
|
mov [pixels_ptr], eax
|
||||||
|
|
||||||
|
cmp [ebx + Image.Type], Image.bpp8
|
||||||
|
jz .rotate_cw8
|
||||||
|
cmp [ebx + Image.Type], Image.bpp24
|
||||||
|
jz .rotate_cw24
|
||||||
|
|
||||||
.next_column_cw_low:
|
.next_column_cw_low:
|
||||||
dec ecx
|
dec ecx
|
||||||
js .exchange_dims
|
js .exchange_dims
|
||||||
@ -586,6 +815,110 @@ endl
|
|||||||
pop ecx
|
pop ecx
|
||||||
jmp .next_column_cw_low
|
jmp .next_column_cw_low
|
||||||
|
|
||||||
|
.rotate_cw8:
|
||||||
|
.next_column_cw_low8:
|
||||||
|
dec ecx
|
||||||
|
js .exchange_dims
|
||||||
|
push ecx
|
||||||
|
|
||||||
|
mov edx, [scanline_len_old]
|
||||||
|
add [scanline_len_old], -1
|
||||||
|
|
||||||
|
mov ecx, [scanline_pixels_new]
|
||||||
|
mov esi, [pixels_ptr]
|
||||||
|
add esi, -1
|
||||||
|
mov edi, [line_buffer]
|
||||||
|
@@: mov al, [esi]
|
||||||
|
mov [edi], al
|
||||||
|
sub esi, edx
|
||||||
|
add edi, 1
|
||||||
|
sub ecx, 1
|
||||||
|
jnz @b
|
||||||
|
|
||||||
|
mov eax, [scanline_pixels_new]
|
||||||
|
dec eax
|
||||||
|
mov edi, [ebx + Image.Data]
|
||||||
|
add edi, [scanline_len_old]
|
||||||
|
lea esi, [edi + 1]
|
||||||
|
mov edx, [scanline_len_old]
|
||||||
|
@@: mov ecx, edx
|
||||||
|
shr ecx, 2
|
||||||
|
rep movsd
|
||||||
|
mov ecx, edx
|
||||||
|
and ecx, 3
|
||||||
|
rep movsb
|
||||||
|
add esi, 1
|
||||||
|
sub eax, 1
|
||||||
|
jnz @b
|
||||||
|
|
||||||
|
mov eax, [scanline_len_new]
|
||||||
|
sub [pixels_ptr], eax
|
||||||
|
mov ecx, eax
|
||||||
|
mov esi, [line_buffer]
|
||||||
|
mov edi, [pixels_ptr]
|
||||||
|
shr ecx, 2
|
||||||
|
rep movsd
|
||||||
|
mov ecx, eax
|
||||||
|
and ecx, 3
|
||||||
|
rep movsb
|
||||||
|
|
||||||
|
pop ecx
|
||||||
|
jmp .next_column_cw_low8
|
||||||
|
|
||||||
|
.rotate_cw24:
|
||||||
|
.next_column_cw_low24:
|
||||||
|
dec ecx
|
||||||
|
js .exchange_dims
|
||||||
|
push ecx
|
||||||
|
|
||||||
|
mov edx, [scanline_len_old]
|
||||||
|
add [scanline_len_old], -3
|
||||||
|
|
||||||
|
mov ecx, [scanline_pixels_new]
|
||||||
|
mov esi, [pixels_ptr]
|
||||||
|
add esi, -3
|
||||||
|
mov edi, [line_buffer]
|
||||||
|
@@: mov al, [esi]
|
||||||
|
mov [edi], al
|
||||||
|
mov al, [esi+1]
|
||||||
|
mov [edi+1], al
|
||||||
|
mov al, [esi+2]
|
||||||
|
mov [edi+2], al
|
||||||
|
sub esi, edx
|
||||||
|
add edi, 3
|
||||||
|
sub ecx, 1
|
||||||
|
jnz @b
|
||||||
|
|
||||||
|
mov eax, [scanline_pixels_new]
|
||||||
|
dec eax
|
||||||
|
mov edi, [ebx + Image.Data]
|
||||||
|
add edi, [scanline_len_old]
|
||||||
|
lea esi, [edi + 3]
|
||||||
|
mov edx, [scanline_len_old]
|
||||||
|
@@: mov ecx, edx
|
||||||
|
shr ecx, 2
|
||||||
|
rep movsd
|
||||||
|
mov ecx, edx
|
||||||
|
and ecx, 3
|
||||||
|
rep movsb
|
||||||
|
add esi, 3
|
||||||
|
sub eax, 1
|
||||||
|
jnz @b
|
||||||
|
|
||||||
|
mov eax, [scanline_len_new]
|
||||||
|
sub [pixels_ptr], eax
|
||||||
|
mov ecx, eax
|
||||||
|
mov esi, [line_buffer]
|
||||||
|
mov edi, [pixels_ptr]
|
||||||
|
shr ecx, 2
|
||||||
|
rep movsd
|
||||||
|
mov ecx, eax
|
||||||
|
and ecx, 3
|
||||||
|
rep movsb
|
||||||
|
|
||||||
|
pop ecx
|
||||||
|
jmp .next_column_cw_low24
|
||||||
|
|
||||||
.flip:
|
.flip:
|
||||||
jmp .exit
|
jmp .exit
|
||||||
|
|
||||||
@ -640,6 +973,17 @@ proc img._.new ;////////////////////////////////////////////////////////////////
|
|||||||
;< eax = 0 / pointer to image ;;
|
;< eax = 0 / pointer to image ;;
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
invoke mem.alloc, sizeof.Image
|
invoke mem.alloc, sizeof.Image
|
||||||
|
test eax, eax
|
||||||
|
jz @f
|
||||||
|
push ecx
|
||||||
|
xor ecx, ecx
|
||||||
|
mov [eax + Image.Data], ecx
|
||||||
|
mov [eax + Image.Type], ecx
|
||||||
|
mov [eax + Image.Extended], ecx
|
||||||
|
mov [eax + Image.Previous], ecx
|
||||||
|
mov [eax + Image.Next], ecx
|
||||||
|
pop ecx
|
||||||
|
@@:
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
@ -674,11 +1018,35 @@ proc img._.resize_data _img, _width, _height ;//////////////////////////////////
|
|||||||
;;------------------------------------------------------------------------------------------------;;
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
;< --- TBD --- ;;
|
;< --- TBD --- ;;
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
push ebx
|
push ebx esi
|
||||||
mov ebx, [_img]
|
mov ebx, [_img]
|
||||||
mov eax, [_height]
|
mov eax, [_height]
|
||||||
|
; our memory is limited, [_width]*[_height] must not overflow
|
||||||
|
; image with width or height greater than 65535 is most likely bogus
|
||||||
|
cmp word [_width+2], 0
|
||||||
|
jnz .error
|
||||||
|
cmp word [_height+2], 0
|
||||||
|
jnz .error
|
||||||
imul eax, [_width]
|
imul eax, [_width]
|
||||||
|
test eax, eax
|
||||||
|
jz .error
|
||||||
|
; do not allow images which require too many memory
|
||||||
|
cmp eax, 4000000h
|
||||||
|
jae .error
|
||||||
|
cmp [ebx + Image.Type], Image.bpp8
|
||||||
|
jz .bpp8
|
||||||
|
cmp [ebx + Image.Type], Image.bpp24
|
||||||
|
jz .bpp24
|
||||||
|
.bpp32:
|
||||||
shl eax, 2
|
shl eax, 2
|
||||||
|
jmp @f
|
||||||
|
.bpp24:
|
||||||
|
lea eax, [eax*3]
|
||||||
|
jmp @f
|
||||||
|
.bpp8:
|
||||||
|
add eax, 256*4 ; for palette
|
||||||
|
@@:
|
||||||
|
mov esi, eax
|
||||||
invoke mem.realloc, [ebx + Image.Data], eax
|
invoke mem.realloc, [ebx + Image.Data], eax
|
||||||
or eax, eax
|
or eax, eax
|
||||||
jz .error
|
jz .error
|
||||||
@ -688,12 +1056,40 @@ proc img._.resize_data _img, _width, _height ;//////////////////////////////////
|
|||||||
pop [ebx + Image.Width]
|
pop [ebx + Image.Width]
|
||||||
push [_height]
|
push [_height]
|
||||||
pop [ebx + Image.Height]
|
pop [ebx + Image.Height]
|
||||||
|
cmp [ebx + Image.Type], Image.bpp8
|
||||||
|
jnz .ret
|
||||||
|
lea esi, [eax + esi - 256*4]
|
||||||
|
mov [ebx + Image.Palette], esi
|
||||||
|
jmp .ret
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
pop ebx
|
xor eax, eax
|
||||||
|
.ret:
|
||||||
|
pop esi ebx
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
|
;;================================================================================================;;
|
||||||
|
img._.get_scanline_len: ;/////////////////////////////////////////////////////////////////////////;;
|
||||||
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
|
;? --- TBD --- ;;
|
||||||
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
|
;> --- TBD --- ;;
|
||||||
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
|
;< --- TBD --- ;;
|
||||||
|
;;================================================================================================;;
|
||||||
|
cmp [ebx + Image.Type], Image.bpp8
|
||||||
|
jz .bpp8.1
|
||||||
|
cmp [ebx + Image.Type], Image.bpp24
|
||||||
|
jz .bpp24.1
|
||||||
|
shl eax, 2
|
||||||
|
jmp @f
|
||||||
|
.bpp24.1:
|
||||||
|
lea eax, [eax*3]
|
||||||
|
.bpp8.1:
|
||||||
|
@@:
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||||
@ -710,7 +1106,7 @@ img._.formats_table:
|
|||||||
; .cur dd img.is.cur, img.decode.cur, img.encode.cur
|
; .cur dd img.is.cur, img.decode.cur, img.encode.cur
|
||||||
.gif dd img.is.gif, img.decode.gif, img.encode.gif
|
.gif dd img.is.gif, img.decode.gif, img.encode.gif
|
||||||
; .png dd img.is.png, img.decode.png, img.encode.png
|
; .png dd img.is.png, img.decode.png, img.encode.png
|
||||||
; .jpg dd img.is.jpg, img.decode.jpg, img.encode.jpg
|
.jpg dd img.is.jpg, img.decode.jpg, img.encode.jpg
|
||||||
dd 0
|
dd 0
|
||||||
|
|
||||||
|
|
||||||
@ -723,7 +1119,7 @@ img._.formats_table:
|
|||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
|
|
||||||
|
|
||||||
align 16
|
align 4
|
||||||
@EXPORT:
|
@EXPORT:
|
||||||
|
|
||||||
export \
|
export \
|
||||||
@ -744,3 +1140,12 @@ export \
|
|||||||
img.unlock_bits , 'img.unlock_bits' , \
|
img.unlock_bits , 'img.unlock_bits' , \
|
||||||
img.flip , 'img.flip' , \
|
img.flip , 'img.flip' , \
|
||||||
img.rotate , 'img.rotate'
|
img.rotate , 'img.rotate'
|
||||||
|
|
||||||
|
section '.data' data readable writable align 16
|
||||||
|
; uninitialized data - global constant tables
|
||||||
|
|
||||||
|
; 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
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
;;//// libimg.inc //// (c) mike.dld, 2007-2008 ///////////////////////////////////////////////////;;
|
;;//// libimg.inc //// (c) mike.dld, 2007-2008, (c) diamond, 2009 ////////////////////////////////;;
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; 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 ;;
|
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
|
||||||
;; General Public License as published by the Free Software Foundation, either version 3 of the ;;
|
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
|
||||||
;; 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 ;;
|
;; 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 ;;
|
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
|
||||||
;; General Public License for more details. ;;
|
;; Lesser General Public License for more details. ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
|
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
|
||||||
;; see <http://www.gnu.org/licenses/>. ;;
|
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
|
|
||||||
@ -30,10 +30,16 @@ struct Image
|
|||||||
Height dd ?
|
Height dd ?
|
||||||
Next dd ?
|
Next dd ?
|
||||||
Previous dd ?
|
Previous dd ?
|
||||||
|
Type dd ? ; one of Image.bppN
|
||||||
Data dd ?
|
Data dd ?
|
||||||
|
Palette dd ? ; used iff Type eq Image.bpp8
|
||||||
Extended dd ?
|
Extended dd ?
|
||||||
ends
|
ends
|
||||||
|
|
||||||
|
Image.bpp8 = 1
|
||||||
|
Image.bpp24 = 2
|
||||||
|
Image.bpp32 = 3
|
||||||
|
|
||||||
FLIP_VERTICAL = 0x01
|
FLIP_VERTICAL = 0x01
|
||||||
FLIP_HORIZONTAL = 0x02
|
FLIP_HORIZONTAL = 0x02
|
||||||
FLIP_BOTH = FLIP_VERTICAL or FLIP_HORIZONTAL
|
FLIP_BOTH = FLIP_VERTICAL or FLIP_HORIZONTAL
|
||||||
|
Loading…
Reference in New Issue
Block a user