new image type: grayscale (Image.bpp9)
tiff fixes for grayscale+alpha images
xcf regression bug fixed (screen mode blending, r2388)


git-svn-id: svn://kolibrios.org@2733 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Ivan Baravy 2012-06-04 03:54:14 +00:00
parent 084abd8134
commit 185caf04b2
16 changed files with 212 additions and 119 deletions

View File

@ -104,7 +104,7 @@ img.decode.bmp.length_rest equ length_rest
jnz .error jnz .error
; convert images with <= 8 bpp to 8bpp, other - to 32 bpp ; convert images with <= 8 bpp to 8bpp, other - to 32 bpp
.normal: .normal:
m2m eax, Image.bpp8 m2m eax, Image.bpp8i
cmp byte [ebx + 14], 8 ; bit count cmp byte [ebx + 14], 8 ; bit count
jbe @f jbe @f
mov al, Image.bpp32 mov al, Image.bpp32
@ -124,7 +124,7 @@ img.decode.bmp.length_rest equ length_rest
pushd [ebx + 4] ;[ebx + bmp.InfoHeader.Width] pushd [ebx + 4] ;[ebx + bmp.InfoHeader.Width]
jmp .create jmp .create
.old1: .old1:
m2m eax, Image.bpp8 m2m eax, Image.bpp8i
cmp byte [ebx + 10], 8 ; bit count cmp byte [ebx + 10], 8 ; bit count
jbe @f jbe @f
mov al, Image.bpp32 mov al, Image.bpp32

View File

@ -209,7 +209,7 @@ img.decode.gif.cur_color_table_size_child equ ebp + 4 + 4 + 4*3 + 4
xor ecx, ecx xor ecx, ecx
@@: @@:
push eax push eax
mov [eax + Image.Type], Image.bpp8 mov [eax + Image.Type], Image.bpp8i
add ecx, sizeof.gif.Image add ecx, sizeof.gif.Image
invoke mem.alloc, ecx invoke mem.alloc, ecx
@ -306,7 +306,7 @@ img.decode.gif.cur_color_table_size_child equ ebp + 4 + 4 + 4*3 + 4
jnz .noprevdata jnz .noprevdata
push 1 push 1
pop eax pop eax
cmp [edx + Image.Type], Image.bpp8 cmp [edx + Image.Type], Image.bpp8i
jz @f jz @f
mov al, 3 mov al, 3
@@: @@:
@ -1259,7 +1259,7 @@ proc img.decode.gif._.dispose ;/////////////////////////////////////////////////
; don't dispose - set prev_img and related vars to current image ; don't dispose - set prev_img and related vars to current image
mov eax, [edx + Image.Data] mov eax, [edx + Image.Data]
mov [prev_img_data], eax mov [prev_img_data], eax
cmp [edx + Image.Type], Image.bpp8 cmp [edx + Image.Type], Image.bpp8i
jnz @f jnz @f
mov eax, [max_color] mov eax, [max_color]
inc eax inc eax

View File

@ -205,7 +205,7 @@ img.decode.ico._.decode_icon_mask:
mov ebx, [eax + Image.Height] mov ebx, [eax + Image.Height]
mov ecx, [eax + Image.Width] mov ecx, [eax + Image.Width]
; for now, BMP code produces only 8 and 32 bpp images ; for now, BMP code produces only 8 and 32 bpp images
cmp [eax + Image.Type], Image.bpp8 cmp [eax + Image.Type], Image.bpp8i
jz .bpp8 jz .bpp8
.bpp32: .bpp32:
mov edx, [esp+16] ; get background color mov edx, [esp+16] ; get background color

View File

@ -473,8 +473,8 @@ img.decode.jpg:
jnz .end2 jnz .end2
; image type: 8 bpp for grayscale JPEGs, 24 bpp for normal, ; image type: 8 bpp for grayscale JPEGs, 24 bpp for normal,
; 32 bpp for Adobe YCCK ; 32 bpp for Adobe YCCK
push Image.bpp8 push Image.bpp8i
pop eax ; Image.bpp8 = 1 pop eax ; Image.bpp8i = 1
cmp edi, eax cmp edi, eax
jz @f jz @f
inc eax ; Image.bpp24 = 2 inc eax ; Image.bpp24 = 2

View File

@ -228,13 +228,13 @@ proc img._.do_rgb ;/////////////////////////////////////////////////////////////
jmp dword [.handlers + (eax-1)*4] jmp dword [.handlers + (eax-1)*4]
align 16 align 16
.bpp8: .bpp8i:
; 8 BPP -> 24 BPP ; 8 BPP WITH PALETTE -> 24 BPP
push ebx push ebx
mov ebx, [esi + Image.Palette] mov ebx, [esi + Image.Palette]
mov esi, [esi + Image.Data] mov esi, [esi + Image.Data]
sub ecx, 1 sub ecx, 1
jz .bpp8.last jz .bpp8i.last
@@: @@:
movzx eax, byte [esi] movzx eax, byte [esi]
add esi, 1 add esi, 1
@ -243,7 +243,7 @@ align 16
add edi, 3 add edi, 3
sub ecx, 1 sub ecx, 1
jnz @b jnz @b
.bpp8.last: .bpp8i.last:
movzx eax, byte [esi] movzx eax, byte [esi]
mov eax, [ebx + eax*4] mov eax, [ebx + eax*4]
mov [edi], ax mov [edi], ax
@ -252,6 +252,32 @@ align 16
pop ebx pop ebx
ret ret
align 16
.bpp8g:
; 8 BPP GRAYSCALE -> 24 BPP
mov esi, [esi + Image.Data]
@@:
lodsb
mov ah, al
stosb
stosw
dec ecx
jnz @b
ret
;
;align 16
;.bpp8a: ; considered application layer, may be changed in the future
;; 8a BPP -> 24 BPP
; mov esi, [esi + Image.Data]
;@@:
; lodsw
; mov ah, al
; stosb
; stosw
; dec ecx
; jnz @b
; ret
; 15 BPP -> 24 BPP ; 15 BPP -> 24 BPP
.bpp15.intel: .bpp15.intel:
push ebx ebp push ebx ebp
@ -972,9 +998,9 @@ endl
jnz .next_line_horz1x jnz .next_line_horz1x
jmp .exit jmp .exit
.bpp8_horz: .bpp8ig_horz:
dec edi dec edi
.next_line_horz8: .next_line_horz8ig:
push ecx esi edi push ecx esi edi
mov ecx, [scanline_len] mov ecx, [scanline_len]
@ -992,7 +1018,7 @@ endl
add esi, [scanline_len] add esi, [scanline_len]
add edi, [scanline_len] add edi, [scanline_len]
dec ecx dec ecx
jnz .next_line_horz8 jnz .next_line_horz8ig
jmp .exit jmp .exit
.bpp24_horz: .bpp24_horz:
@ -1180,8 +1206,10 @@ endl
cmp [ebx + Image.Type], Image.bpp1 cmp [ebx + Image.Type], Image.bpp1
jz .rotate_ccw1 jz .rotate_ccw1
cmp [ebx + Image.Type], Image.bpp8 cmp [ebx + Image.Type], Image.bpp8i
jz .rotate_ccw8 jz .rotate_ccw8ig
cmp [ebx + Image.Type], Image.bpp8g
jz .rotate_ccw8ig
cmp [ebx + Image.Type], Image.bpp24 cmp [ebx + Image.Type], Image.bpp24
jz .rotate_ccw24 jz .rotate_ccw24
cmp [ebx + Image.Type], Image.bpp32 cmp [ebx + Image.Type], Image.bpp32
@ -1273,8 +1301,8 @@ endl
pop ecx pop ecx
jmp .next_column_ccw_low jmp .next_column_ccw_low
.rotate_ccw8: .rotate_ccw8ig:
.next_column_ccw_low8: .next_column_ccw_low8ig:
dec ecx dec ecx
js .exchange_dims js .exchange_dims
push ecx push ecx
@ -1319,7 +1347,7 @@ endl
rep movsb rep movsb
pop ecx pop ecx
jmp .next_column_ccw_low8 jmp .next_column_ccw_low8ig
.rotate_ccw24: .rotate_ccw24:
.next_column_ccw_low24: .next_column_ccw_low24:
@ -1472,8 +1500,10 @@ endl
cmp [ebx + Image.Type], Image.bpp1 cmp [ebx + Image.Type], Image.bpp1
jz .rotate_cw1 jz .rotate_cw1
cmp [ebx + Image.Type], Image.bpp8 cmp [ebx + Image.Type], Image.bpp8i
jz .rotate_cw8 jz .rotate_cw8ig
cmp [ebx + Image.Type], Image.bpp8g
jz .rotate_cw8ig
cmp [ebx + Image.Type], Image.bpp24 cmp [ebx + Image.Type], Image.bpp24
jz .rotate_cw24 jz .rotate_cw24
cmp [ebx + Image.Type], Image.bpp32 cmp [ebx + Image.Type], Image.bpp32
@ -1570,8 +1600,8 @@ endl
pop ecx pop ecx
jmp .next_column_cw_low jmp .next_column_cw_low
.rotate_cw8: .rotate_cw8ig:
.next_column_cw_low8: .next_column_cw_low8ig:
dec ecx dec ecx
js .exchange_dims js .exchange_dims
push ecx push ecx
@ -1618,7 +1648,7 @@ endl
rep movsb rep movsb
pop ecx pop ecx
jmp .next_column_cw_low8 jmp .next_column_cw_low8ig
.rotate_cw24: .rotate_cw24:
.next_column_cw_low24: .next_column_cw_low24:
@ -1889,7 +1919,7 @@ img.formats_table:
.pcx dd LIBIMG_FORMAT_ID_PCX, img.is.pcx, img.decode.pcx, img.encode.pcx, 0 .pcx dd LIBIMG_FORMAT_ID_PCX, img.is.pcx, img.decode.pcx, img.encode.pcx, 0
.xcf dd LIBIMG_FORMAT_ID_XCF, img.is.xcf, img.decode.xcf, img.encode.xcf, 0 .xcf dd LIBIMG_FORMAT_ID_XCF, img.is.xcf, img.decode.xcf, img.encode.xcf, 0
.tiff dd LIBIMG_FORMAT_ID_TIFF, img.is.tiff, img.decode.tiff, img.encode.tiff,0 .tiff dd LIBIMG_FORMAT_ID_TIFF, img.is.tiff, img.decode.tiff, img.encode.tiff,0
.pnm dd LIBIMG_FORMAT_ID_PNM, img.is.pnm, img.decode.pnm, img.encode.pnm, 1 + (1 SHL Image.bpp1) + (1 SHL Image.bpp8) + (1 SHL Image.bpp24) .pnm dd LIBIMG_FORMAT_ID_PNM, img.is.pnm, img.decode.pnm, img.encode.pnm, 1 + (1 SHL Image.bpp1) + (1 SHL Image.bpp8g) + (1 SHL Image.bpp24)
.wbmp dd LIBIMG_FORMAT_ID_WBMP, img.is.wbmp, img.decode.wbmp, img.encode.wbmp,0 .wbmp dd LIBIMG_FORMAT_ID_WBMP, img.is.wbmp, img.decode.wbmp, img.encode.wbmp,0
.z80 dd LIBIMG_FORMAT_ID_Z80, img.is.z80, img.decode.z80, img.encode.z80, 0 ;this must be the last entry as there are no signatures in z80 screens at all .z80 dd LIBIMG_FORMAT_ID_Z80, img.is.z80, img.decode.z80, img.encode.z80, 0 ;this must be the last entry as there are no signatures in z80 screens at all
dd 0 dd 0
@ -1989,8 +2019,12 @@ proc img._.resize_data _img, _width, _height ;//////////////////////////////////
jae .error jae .error
cmp [ebx + Image.Type], Image.bpp1 cmp [ebx + Image.Type], Image.bpp1
jz .bpp1 jz .bpp1
cmp [ebx + Image.Type], Image.bpp8 cmp [ebx + Image.Type], Image.bpp8i
jz .bpp8 jz .bpp8i
cmp [ebx + Image.Type], Image.bpp8g
jz .bpp8g
cmp [ebx + Image.Type], Image.bpp8a
jz .bpp8a
cmp [ebx + Image.Type], Image.bpp24 cmp [ebx + Image.Type], Image.bpp24
jz .bpp24 jz .bpp24
.bpp32: .bpp32:
@ -1999,8 +2033,12 @@ proc img._.resize_data _img, _width, _height ;//////////////////////////////////
.bpp24: .bpp24:
lea eax, [eax*3] lea eax, [eax*3]
jmp @f jmp @f
.bpp8: .bpp8i:
add eax, 256*4 ; for palette add eax, 256*4 ; for palette
.bpp8g:
jmp @f
.bpp8a:
shl eax, 1
jmp @f jmp @f
.bpp1: .bpp1:
mov eax, [_width] mov eax, [_width]
@ -2040,7 +2078,7 @@ 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 cmp [ebx + Image.Type], Image.bpp8i
jnz @f jnz @f
lea esi, [eax + esi - 256*4] lea esi, [eax + esi - 256*4]
mov [ebx + Image.Palette], esi mov [ebx + Image.Palette], esi
@ -2070,8 +2108,12 @@ img._.get_scanline_len: ;///////////////////////////////////////////////////////
;;================================================================================================;; ;;================================================================================================;;
cmp [ebx + Image.Type], Image.bpp1 cmp [ebx + Image.Type], Image.bpp1
jz .bpp1.1 jz .bpp1.1
cmp [ebx + Image.Type], Image.bpp8 cmp [ebx + Image.Type], Image.bpp8i
jz .bpp8.1 jz .bpp8.1
cmp [ebx + Image.Type], Image.bpp8g
jz .bpp8.1
cmp [ebx + Image.Type], Image.bpp8a
jz .bpp8a.1
cmp [ebx + Image.Type], Image.bpp24 cmp [ebx + Image.Type], Image.bpp24
jz .bpp24.1 jz .bpp24.1
add eax, eax add eax, eax
@ -2085,6 +2127,9 @@ img._.get_scanline_len: ;///////////////////////////////////////////////////////
.bpp1.1: .bpp1.1:
add eax, 7 add eax, 7
shr eax, 3 shr eax, 3
jmp .quit
.bpp8a.1:
shl eax, 1
.bpp8.1: .bpp8.1:
.quit: .quit:
ret ret
@ -2099,22 +2144,26 @@ img._.get_scanline_len: ;///////////////////////////////////////////////////////
;;================================================================================================;; ;;================================================================================================;;
align 4 align 4
type2bpp dd 8, 24, 32, 15, 16, 1 type2bpp dd 8, 24, 32, 15, 16, 1, 9 ;,16
img._.do_rgb.handlers: img._.do_rgb.handlers:
dd img._.do_rgb.bpp8 dd img._.do_rgb.bpp8i
dd img._.do_rgb.bpp24 dd img._.do_rgb.bpp24
dd img._.do_rgb.bpp32 dd img._.do_rgb.bpp32
dd img._.do_rgb.bpp15.amd ; can be overwritten in lib_init dd img._.do_rgb.bpp15.amd ; can be overwritten in lib_init
dd img._.do_rgb.bpp16.amd ; can be overwritten in lib_init dd img._.do_rgb.bpp16.amd ; can be overwritten in lib_init
dd img._.do_rgb.bpp1 dd img._.do_rgb.bpp1
dd img._.do_rgb.bpp8g
; dd img._.do_rgb.bpp8a
img.flip.layer.handlers_horz: img.flip.layer.handlers_horz:
dd img.flip.layer.bpp8_horz dd img.flip.layer.bpp8ig_horz
dd img.flip.layer.bpp24_horz dd img.flip.layer.bpp24_horz
dd img.flip.layer.bpp32_horz dd img.flip.layer.bpp32_horz
dd img.flip.layer.bpp1x_horz dd img.flip.layer.bpp1x_horz
dd img.flip.layer.bpp1x_horz dd img.flip.layer.bpp1x_horz
dd img.flip.layer.bpp1_horz dd img.flip.layer.bpp1_horz
dd img.flip.layer.bpp8ig_horz
; dd img.flip.layer.bpp8a_horz
;;================================================================================================;; ;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;;

View File

@ -69,13 +69,15 @@ ends
; values for Image.Type ; values for Image.Type
; must be consecutive to allow fast switch on Image.Type in support functions ; must be consecutive to allow fast switch on Image.Type in support functions
Image.bpp8 = 1 Image.bpp8i = 1 ; indexed
Image.bpp24 = 2 Image.bpp24 = 2
Image.bpp32 = 3 Image.bpp32 = 3
Image.bpp15 = 4 Image.bpp15 = 4
Image.bpp16 = 5 Image.bpp16 = 5
Image.bpp1 = 6 Image.bpp1 = 6
Image.bpp4 = 7 Image.bpp8g = 7 ; grayscale
Image.bpp8a = 8 ; grayscale with alpha channel; application layer only!!! kernel doesn't handle this image type, libimg can only create and destroy such images
;Image.bpp4 = 9
; bits in Image.Flags ; bits in Image.Flags
Image.IsAnimated = 1 Image.IsAnimated = 1

View File

@ -157,7 +157,7 @@ endl
.indexed: .indexed:
stdcall img.create, eax, ebx, Image.bpp8 stdcall img.create, eax, ebx, Image.bpp8i
mov [retvalue], eax mov [retvalue], eax
test eax, eax test eax, eax
jz .quit jz .quit

View File

@ -239,7 +239,7 @@ end virtual
mov al, Image.bpp32 mov al, Image.bpp32
cmp [.color_type], 6 cmp [.color_type], 6
jz @f jz @f
mov al, Image.bpp8 mov al, Image.bpp8i
@@: @@:
stdcall img.create, [.width], [.height], eax stdcall img.create, [.width], [.height], eax
test eax, eax test eax, eax

View File

@ -1,17 +1,10 @@
.pgm: .pgm:
stdcall img.create, [width], [height], Image.bpp8 stdcall img.create, [width], [height], Image.bpp8g
test eax, eax test eax, eax
jz .quit jz .quit
mov [retvalue], eax mov [retvalue], eax
mov ebx, eax mov ebx, eax
mov edi, [ebx+Image.Palette]
mov eax, 0xff000000
@@:
stosd
add eax, 0x00010101
jnc @b
mov edi, [ebx+Image.Data] mov edi, [ebx+Image.Data]
mov ecx, [ebx+Image.Width] mov ecx, [ebx+Image.Width]
imul ecx, [ebx+Image.Height] imul ecx, [ebx+Image.Height]

View File

@ -204,7 +204,7 @@ endl
mov eax, [ebx + Image.Type] mov eax, [ebx + Image.Type]
cmp eax, Image.bpp1 cmp eax, Image.bpp1
je .pbm je .pbm
cmp eax, Image.bpp8 cmp eax, Image.bpp8g
je .pgm je .pgm
cmp eax, Image.bpp24 cmp eax, Image.bpp24
je .ppm je .ppm

View File

@ -18,7 +18,6 @@
;;================================================================================================;; ;;================================================================================================;;
include 'tiff.inc' include 'tiff.inc'
;include '../../../../../system/board/trunk/debug.inc'
;;================================================================================================;; ;;================================================================================================;;
proc img.is.tiff _data, _length ;/////////////////////////////////////////////////////////////////;; proc img.is.tiff _data, _length ;/////////////////////////////////////////////////////////////////;;
@ -185,7 +184,7 @@ endl
mov ecx, [edx + Image.Type] mov ecx, [edx + Image.Type]
dec ecx dec ecx
jz .bpp8 jz .bpp8i
dec ecx dec ecx
jz .bpp24 jz .bpp24
dec ecx dec ecx
@ -196,7 +195,9 @@ endl
dec ecx dec ecx
jz .bpp1 jz .bpp1
dec ecx dec ecx
jz .bpp4 jz .bpp8g
dec ecx
jz .bpp8a
;error report!! ;error report!!
.bpp1: .bpp1:
@ -216,10 +217,7 @@ endl
.bpp4: .bpp4:
jmp .common jmp .common
.bpp8: .bpp8i:
cmp [ebx + tiff_extra.palette], 0
je .bpp8.grayscale
mov esi, [ebx + tiff_extra.palette] mov esi, [ebx + tiff_extra.palette]
mov ah, 2 mov ah, 2
.bpp8.channel: .bpp8.channel:
@ -238,13 +236,10 @@ endl
dec ah dec ah
jns .bpp8.channel jns .bpp8.channel
jmp .common jmp .common
.bpp8.grayscale: .bpp8g:
mov edi, [edx + Image.Palette] jmp .common
mov eax, 0xff000000
@@: .bpp8a:
stosd
add eax, 0x00010101
jnc @b
jmp .common jmp .common
.bpp16: .bpp16:
@ -346,8 +341,9 @@ endl
.decoded: .decoded:
.check1:
cmp [ebx + tiff_extra.samples_per_pixel], 3 cmp [ebx + tiff_extra.samples_per_pixel], 3
jne .pop_quit jne .check2
mov eax, [retvalue] mov eax, [retvalue]
mov esi, [eax + Image.Data] mov esi, [eax + Image.Data]
mov edi, [eax + Image.Data] mov edi, [eax + Image.Data]
@ -360,7 +356,26 @@ endl
add edi, 2 add edi, 2
dec ecx dec ecx
jnz @b jnz @b
jmp .pop_quit
.check2:
mov ebx, [retvalue]
cmp [ebx + Image.Type], Image.bpp8a
jne .pop_quit
stdcall tiff._.pack_8a, ebx
mov [ebx + Image.Type], Image.bpp8g
; mov eax, [ebx + Image.Width]
; imul eax, [ebx + Image.Height]
; mov ecx, eax
; add ecx, [ebx + Image.Data]
; mov [ebx + Image.Palette], ecx
; add eax, 256*4
; stdcall [mem.realloc], [ebx + Image.Data], eax
; mov edi, [ebx + Image.Palette]
; mov eax, 0xff000000
; @@:
; stosd
; add eax, 0x00010101
; jnc @b
.pop_quit: .pop_quit:
pop esi pop esi
@ -386,13 +401,13 @@ proc tiff._.parse_IFDE _data, _endianness
add edx, 8 add edx, 8
dec ecx dec ecx
jnz .tag jnz .tag
.tag_default: ; unknown/unsupported/uninteresting/unimportant .tag_default: ; unknown/unsupported/uninteresting/unimportant
lodsw lodsw
lodsd lodsd
lodsd lodsd
jmp .quit ; just skip it jmp .quit ; just skip it
.tag_100: .tag_100: ; ImageWidth
cmp ax, TIFF.IFDE_TYPE.SHORT cmp ax, TIFF.IFDE_TYPE.SHORT
jne @f jne @f
lodsd lodsd
@ -411,7 +426,7 @@ proc tiff._.parse_IFDE _data, _endianness
@@: @@:
jmp .quit jmp .quit
.tag_101: .tag_101: ; ImageHeight
cmp ax, TIFF.IFDE_TYPE.SHORT cmp ax, TIFF.IFDE_TYPE.SHORT
jne @f jne @f
lodsd lodsd
@ -430,7 +445,7 @@ proc tiff._.parse_IFDE _data, _endianness
@@: @@:
jmp .quit jmp .quit
.tag_102: .tag_102: ; BitsPerSample
lodsd_ lodsd_
imul eax, TIFF.IFDE_TYPE_LENGTH.SHORT imul eax, TIFF.IFDE_TYPE_LENGTH.SHORT
cmp eax, 4 cmp eax, 4
@ -451,7 +466,7 @@ proc tiff._.parse_IFDE _data, _endianness
mov [ebx + tiff_extra.bits_per_sample], eax mov [ebx + tiff_extra.bits_per_sample], eax
jmp .quit jmp .quit
.tag_103: .tag_103: ; Compression
cmp ax, TIFF.IFDE_TYPE.SHORT cmp ax, TIFF.IFDE_TYPE.SHORT
jne @f jne @f
lodsd lodsd
@ -463,7 +478,7 @@ proc tiff._.parse_IFDE _data, _endianness
@@: @@:
jmp .quit jmp .quit
.tag_106: .tag_106: ; PhotometricInterpretation
cmp ax, TIFF.IFDE_TYPE.SHORT cmp ax, TIFF.IFDE_TYPE.SHORT
jne @f jne @f
lodsd lodsd
@ -476,7 +491,7 @@ proc tiff._.parse_IFDE _data, _endianness
jmp .quit jmp .quit
.tag_111: .tag_111: ; StripOffsets
cmp ax, TIFF.IFDE_TYPE.SHORT cmp ax, TIFF.IFDE_TYPE.SHORT
jne @f jne @f
mov [ebx + tiff_extra.strip_offsets_length], TIFF.IFDE_TYPE_LENGTH.SHORT mov [ebx + tiff_extra.strip_offsets_length], TIFF.IFDE_TYPE_LENGTH.SHORT
@ -498,7 +513,7 @@ proc tiff._.parse_IFDE _data, _endianness
mov [ebx + tiff_extra.strip_offsets], eax mov [ebx + tiff_extra.strip_offsets], eax
jmp .quit jmp .quit
.tag_115: .tag_115: ; SamplesPerPixel
lodsd_ lodsd_
imul eax, TIFF.IFDE_TYPE_LENGTH.SHORT imul eax, TIFF.IFDE_TYPE_LENGTH.SHORT
cmp eax, 4 cmp eax, 4
@ -514,7 +529,7 @@ proc tiff._.parse_IFDE _data, _endianness
movzx eax, word[eax] movzx eax, word[eax]
jmp .quit jmp .quit
.tag_116: .tag_116: ; RowsPerStrip
cmp ax, TIFF.IFDE_TYPE.SHORT cmp ax, TIFF.IFDE_TYPE.SHORT
jne @f jne @f
lodsd lodsd
@ -529,7 +544,7 @@ proc tiff._.parse_IFDE _data, _endianness
mov [ebx + tiff_extra.rows_per_strip], eax mov [ebx + tiff_extra.rows_per_strip], eax
jmp .quit jmp .quit
.tag_117: .tag_117: ; StripByteCounts
cmp ax, TIFF.IFDE_TYPE.SHORT cmp ax, TIFF.IFDE_TYPE.SHORT
jne @f jne @f
mov [ebx + tiff_extra.strip_byte_counts_length], TIFF.IFDE_TYPE_LENGTH.SHORT mov [ebx + tiff_extra.strip_byte_counts_length], TIFF.IFDE_TYPE_LENGTH.SHORT
@ -550,12 +565,17 @@ proc tiff._.parse_IFDE _data, _endianness
mov [ebx + tiff_extra.strip_byte_counts], eax mov [ebx + tiff_extra.strip_byte_counts], eax
jmp .quit jmp .quit
.tag_140: .tag_140: ; ColorMap
lodsd lodsd
lodsd_ lodsd_
add eax, [_data] add eax, [_data]
mov [ebx + tiff_extra.palette], eax mov [ebx + tiff_extra.palette], eax
jmp .quit jmp .quit
.tag_152: ; ExtraSamples
mov [ebx + tiff_extra.extra_samples], esi
mov ecx, [ebx + tiff_extra.extra_samples_number]
rep lodsw ; ignored
jmp .quit
.quit: .quit:
pop edi edx ebx pop edi edx ebx
@ -567,42 +587,51 @@ proc tiff._.define_image_type
xor eax, eax xor eax, eax
cmp [ebx + tiff_extra.photometric], TIFF.PHOTOMETRIC.RGB
jne .not_full_color
mov eax, -3
add eax, [ebx + tiff_extra.samples_per_pixel]
mov [ebx + tiff_extra.extra_samples_number], eax
dec eax
jns @f
mov eax, Image.bpp24
jmp .quit
@@:
dec eax
jns @f
mov eax, Image.bpp32
; mov [ebx + tiff_extra.extra_samples_number], 0
jmp .quit
@@:
.not_full_color: ; grayscale, indexed, bilevel
cmp [ebx + tiff_extra.bits_per_sample], 1 cmp [ebx + tiff_extra.bits_per_sample], 1
jg .not_bilevel jg .not_bilevel
mov eax, Image.bpp1 mov eax, Image.bpp1
jmp .quit jmp .quit
.not_bilevel: .not_bilevel: ; grayscale, indexed
cmp [ebx + tiff_extra.palette], 0 cmp [ebx + tiff_extra.palette], 0
je .without_palette je .without_palette
cmp [ebx + tiff_extra.bits_per_sample], 4 cmp [ebx + tiff_extra.bits_per_sample], 4
jne @f jne @f
mov eax, Image.bpp4 ; mov eax, Image.bpp4
jmp .quit jmp .quit
@@: @@:
cmp [ebx + tiff_extra.bits_per_sample], 8 cmp [ebx + tiff_extra.bits_per_sample], 8
jne @f jne @f
mov eax, Image.bpp8 mov eax, Image.bpp8i
jmp .quit jmp .quit
@@: @@:
jmp .quit jmp .quit
.without_palette: .without_palette: ; grayscale
cmp [ebx + tiff_extra.samples_per_pixel], 1 mov eax, -1
jg .not_grayscale add eax, [ebx + tiff_extra.samples_per_pixel]
cmp [ebx + tiff_extra.bits_per_sample], 4 mov [ebx + tiff_extra.extra_samples_number], eax
jne @f dec eax
mov eax, Image.bpp4 jns @f
jmp .quit mov eax, Image.bpp8g
@@:
cmp [ebx + tiff_extra.bits_per_sample], 8
jne @f
mov eax, Image.bpp8
jmp .quit
.not_grayscale:
cmp [ebx + tiff_extra.samples_per_pixel], 3
jne @f
mov eax, Image.bpp24
jmp .quit jmp .quit
@@: @@:
mov eax, Image.bpp8a
jmp .quit jmp .quit
.quit: .quit:
ret ret
@ -830,6 +859,20 @@ proc tiff._.get_dword _endianness
endp endp
proc tiff._.pack_8a _img
mov ebx, [_img]
mov esi, [ebx + Image.Data]
mov edi, esi
mov ecx, [ebx + Image.Width]
imul ecx, [ebx + Image.Height]
@@:
lodsw
stosb
dec ecx
jnz @b
ret
endp
;;================================================================================================;; ;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
@ -848,6 +891,7 @@ tiff.IFDE_tag_table.begin:
.tag_116: dd 0x0116, tiff._.parse_IFDE.tag_116 ; rows per strip .tag_116: dd 0x0116, tiff._.parse_IFDE.tag_116 ; rows per strip
.tag_117: dd 0x0117, tiff._.parse_IFDE.tag_117 ; strip byte counts .tag_117: dd 0x0117, tiff._.parse_IFDE.tag_117 ; strip byte counts
.tag_140: dd 0x0140, tiff._.parse_IFDE.tag_140 ; color map .tag_140: dd 0x0140, tiff._.parse_IFDE.tag_140 ; color map
.tag_152: dd 0x0152, tiff._.parse_IFDE.tag_152 ; extra samples
tiff.IFDE_tag_table.end: tiff.IFDE_tag_table.end:
include 'huffman.asm' ; huffman trees for ccitt1d compression method include 'huffman.asm' ; huffman trees for ccitt1d compression method

View File

@ -38,6 +38,8 @@ struct tiff_extra
strip_byte_counts_length rd 1 strip_byte_counts_length rd 1
palette rd 1 ; SHORT palette rd 1 ; SHORT
palette_size rd 1 ; in colors, not samples palette_size rd 1 ; in colors, not samples
extra_samples rd 1 ; pointer to array of SHORTs
extra_samples_number rd 1
ends ends

View File

@ -387,13 +387,15 @@ proc xcf._.composite_rgb_04 ; Screen
punpcklbw mm2, mm0 punpcklbw mm2, mm0
punpcklbw mm3, mm0 punpcklbw mm3, mm0
movq mm5, [xcf._.mmx_00ff] movq mm4, [xcf._.mmx_00ff]
movq mm4, mm5 movq mm5, mm4
psubw mm5, mm3
movq mm3, mm4
psubw mm4, mm2 psubw mm4, mm2
psubw mm3, mm5 pmullw mm4, mm5
pmullw mm3, mm4 psrlw mm4, 8
psrlw mm3, 8 psubw mm3, mm4
paddw mm3, mm5
ret ret
endp endp

View File

@ -583,13 +583,14 @@ proc xcf._.composite_rgb_04 ; Screen
punpcklbw xmm2, xmm0 punpcklbw xmm2, xmm0
punpcklbw xmm3, xmm0 punpcklbw xmm3, xmm0
movdqu xmm5, xword[xcf._.xmm_00ff] movdqu xmm4, xword[xcf._.xmm_00ff]
movdqa xmm4, xmm5 movdqa xmm5, xmm4
psubw xmm5, xmm3
movdqa xmm3, xmm4
psubw xmm4, xmm2 psubw xmm4, xmm2
psubw xmm3, xmm5 pmullw xmm4, xmm5
pmullw xmm3, xmm4 psrlw xmm4, 8
psrlw xmm3, 8 psubw xmm3, xmm4
paddw xmm3, xmm5
ret ret
endp endp

View File

@ -130,7 +130,7 @@ endl
.process_grayscale: .process_grayscale:
stdcall img.create, ebx, edx, Image.bpp8 stdcall img.create, ebx, edx, Image.bpp8i
mov [retvalue], eax mov [retvalue], eax
test eax, eax test eax, eax
jz .error jz .error
@ -160,7 +160,7 @@ endl
.process_indexed: .process_indexed:
stdcall img.create, ebx, edx, Image.bpp8 stdcall img.create, ebx, edx, Image.bpp8i
mov [retvalue], eax mov [retvalue], eax
test eax, eax test eax, eax
jz .error jz .error
@ -217,7 +217,7 @@ endl
dec [layer_count] dec [layer_count]
jnz .still jnz .still
cmp [ebx + Image.Type], Image.bpp8 cmp [ebx + Image.Type], Image.bpp8i
jne .quit jne .quit
stdcall xcf._.pack_8a, ebx stdcall xcf._.pack_8a, ebx
jmp .quit jmp .quit
@ -372,7 +372,7 @@ endl
bswap eax bswap eax
add esi, eax add esi, eax
stdcall img.create, [channel_width], [channel_height], Image.bpp8 stdcall img.create, [channel_width], [channel_height], Image.bpp8i
mov ebx, eax mov ebx, eax
test ebx, ebx test ebx, ebx
jz .quit jz .quit
@ -443,7 +443,7 @@ endl
mov [layer_height], eax mov [layer_height], eax
lodsd lodsd
bswap eax bswap eax
mov edx, Image.bpp16 mov edx, Image.bpp8a
mov [color_step], 1 mov [color_step], 1
cmp eax, 2 cmp eax, 2
jge @f jge @f
@ -899,7 +899,7 @@ endl
imul eax, [img_y1] imul eax, [img_y1]
add eax, [img_x1] add eax, [img_x1]
shl eax, 1 shl eax, 1
cmp [edx + Image.Width], Image.bpp16 cmp [edx + Image.Width], Image.bpp8a
je @f je @f
shl eax, 1 shl eax, 1
@@: @@:
@ -909,7 +909,7 @@ endl
imul eax, [bottom_y1] imul eax, [bottom_y1]
add eax, [bottom_x1] add eax, [bottom_x1]
shl eax, 1 shl eax, 1
cmp [ebx + Image.Width], Image.bpp8 cmp [ebx + Image.Width], Image.bpp8i
je @f je @f
shl eax, 1 shl eax, 1
@@: @@:
@ -919,7 +919,7 @@ endl
mov eax, [edx + Image.Width] mov eax, [edx + Image.Width]
sub eax, [copy_width] sub eax, [copy_width]
shl eax, 1 shl eax, 1
cmp [edx + Image.Width], Image.bpp16 cmp [edx + Image.Width], Image.bpp8a
je @f je @f
shl eax, 1 shl eax, 1
@@: @@:
@ -928,7 +928,7 @@ endl
mov eax, [ebx + Image.Width] mov eax, [ebx + Image.Width]
sub eax, [copy_width] sub eax, [copy_width]
shl eax, 1 shl eax, 1
cmp [ebx + Image.Width], Image.bpp8 cmp [ebx + Image.Width], Image.bpp8i
je @f je @f
shl eax, 1 shl eax, 1
@@: @@:
@ -938,7 +938,7 @@ endl
jne .not_first jne .not_first
mov ecx, [copy_width] mov ecx, [copy_width]
imul ecx, [copy_height] imul ecx, [copy_height]
cmp [ebx + Image.Type], Image.bpp8 cmp [ebx + Image.Type], Image.bpp8i
je .bpp8a je .bpp8a
.bpp32: .bpp32:
rep movsd rep movsd
@ -997,7 +997,7 @@ endl
@@: @@:
cmp [ebx + Image.Type], Image.bpp8 cmp [ebx + Image.Type], Image.bpp8i
jne @f jne @f
stdcall xcf._.merge_8a, [copy_width], [copy_height], [img_total_bpl], [bottom_total_bpl] stdcall xcf._.merge_8a, [copy_width], [copy_height], [img_total_bpl], [bottom_total_bpl]
jmp .done jmp .done

View File

@ -71,7 +71,7 @@ endl
xor eax,eax xor eax,eax
pushad pushad
cld ;paranoia cld ;paranoia
stdcall img.create,256,192,Image.bpp8 stdcall img.create,256,192,Image.bpp8i
test eax,eax test eax,eax
jz img.decode.z80.locret ;test if allocation failed jz img.decode.z80.locret ;test if allocation failed
mov [frame1],eax mov [frame1],eax
@ -101,7 +101,7 @@ endl
.decode_z80_with_blinking: .decode_z80_with_blinking:
or ebx,0xFFFF0000 ;use DualStos or ebx,0xFFFF0000 ;use DualStos
mov ecx,eax ;eax still points to the first frame mov ecx,eax ;eax still points to the first frame
stdcall img.create,256,192,Image.bpp8 stdcall img.create,256,192,Image.bpp8i
test eax,eax test eax,eax
jz img.decode.z80.failed jz img.decode.z80.failed
mov [eax+Image.Previous],ecx mov [eax+Image.Previous],ecx