MV: support for RLE8 compression and files with reversed rows order (negative height)

git-svn-id: svn://kolibrios.org@190 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Evgeny Grechnikov (Diamond) 2006-10-23 12:54:00 +00:00
parent ad550e216e
commit 4708579954

View File

@ -1,5 +1,6 @@
; Picture browser by lisovin@26.ru ; Picture browser by lisovin@26.ru
; Modified by Ivan Poddubny - v.0.3 ; Modified by Ivan Poddubny - v.0.3
; Modified by Diamond - v.0.4
; Compile with FASM for Menuet ; Compile with FASM for Menuet
;****************************************************************************** ;******************************************************************************
@ -194,6 +195,10 @@ load_image:
int 0x40 int 0x40
mov eax,[I_END+18] mov eax,[I_END+18]
mov ebx,[I_END+22] mov ebx,[I_END+22]
test ebx, ebx
jns @f
neg ebx
@@:
add eax,20 add eax,20
cmp eax,210 cmp eax,210
jae @f jae @f
@ -223,9 +228,12 @@ load_image:
jne nodrawimage jne nodrawimage
mov eax,7 mov eax,7
mov ebx,[soi] mov ebx,[soi]
mov ecx,[I_END+18] mov ecx, dword [I_END+18-2]
shl ecx,16 mov cx, [I_END+22]
add ecx,[I_END+22] test cx, cx
jns @f
neg cx
@@:
mov edx,10*65536+50 mov edx,10*65536+50
int 0x40 int 0x40
nodrawimage: nodrawimage:
@ -260,124 +268,169 @@ load_image:
ret ret
convert: convert:
mov ecx, I_END
add ecx, [ecx+2]
mov [soi], ecx
mov ebp, [I_END+18]
lea ebp, [ebp*3] ; ebp = size of output scanline
mov eax, [I_END+22]
dec eax
mul ebp
add eax, ecx
mov edi, eax ; edi points to last scanline
mov esi, I_END
add esi, [esi+10]
mov ebx, I_END+54
mov edx, [I_END+22]
lea eax, [ebp*2]
mov [delta], eax
test edx, edx
jz .ret
jns @f
neg edx
and [delta], 0
mov edi, ecx
@@:
movzx eax, word [I_END+28] movzx eax, word [I_END+28]
mul dword [I_END+18] cmp eax, 24
; mov ebx,32 jz convert24
; div ebx cmp eax, 8
; test edx,edx jz convert8
; je noaddword cmp eax, 4
; inc eax jz convert4
; noaddword: dec eax
add eax, 31 jz convert1
shr eax, 5 .ret:
mov [dwps],eax ;dwps-doublewords per string ret
shl eax,2 convert24:
mov [bps],eax ;bps-bytes per string mov ecx, ebp
rep movsb
cmp dword [I_END+34],0 sub edi, [delta]
jne yespicsize ;if picture size is defined mov eax, ebp
mul dword [I_END+22] neg eax
mov dword [I_END+34],eax and eax, 3
add esi, eax
yespicsize: dec edx
mov eax,I_END jnz convert24
push eax ret
add eax, [I_END+2];file size convert8:
inc eax
mov [soi],eax ;soi-start of image area for drawing
pop eax
add eax, [I_END+10]
mov [sop],eax ;sop-start of picture in file
add eax, [I_END+34]
mov [eop],eax ;eop-end of picture in file
mov eax, [I_END+18]
mov ebx,3
mul ebx ;3x pixels in eax
mov edi,[soi] ;initializing
mov esi,[eop]
sub esi,[bps]
nextstring:
push edi push edi
cmp word [I_END+28],24 add [esp], ebp
jne convertno32 .loopi:
xor eax, eax
mov ecx,[dwps] lodsb
cld cmp dword [I_END+30], 1
rep movsd jnz .nocompressed
convert1: .compressed:
mov ecx, eax
jecxz .special
lodsb
mov eax, [ebx+eax*4]
@@:
call putpixel
loop @b
jmp .loopi
.nocompressed:
mov eax, [ebx+eax*4]
call putpixel
.loopicont:
cmp edi, [esp]
jnz .loopi
.next:
pop edi pop edi
sub esi,[bps] sub edi, [delta]
sub esi,[bps] mov eax, ebp
cmp esi,[sop] and eax, 3
jb nomorestring add esi, eax
add edi,eax dec edx
jmp nextstring jnz convert8
ret
nomorestring: .special:
lodsb
test al, al
jz .next
cmp al, 2
jbe .end
mov ecx, eax
push ecx
@@:
xor eax, eax
lodsb
mov eax, [ebx+eax*4]
call putpixel
loop @b
pop ecx
and ecx, 1
add esi, ecx
jmp .loopi
.end:
pop edi
ret
convert4:
push edi
add [esp], ebp
.loopi:
xor eax, eax
lodsb
shr eax, 4
mov eax, [ebx+eax*4]
call putpixel
cmp edi, [esp]
jz .loopidone
mov al, [esi-1]
and eax, 0xF
mov eax, [ebx+eax*4]
stosd
dec edi
cmp edi, [esp]
jnz .loopi
.loopidone:
pop edi
sub edi, [delta]
call align_input
dec edx
jnz convert4
ret
convert1:
push edi
add [esp], ebp
.loopi:
lodsb
mov ecx, 8
.loopii:
add al, al
push eax
setc al
movzx eax, al
mov eax, [ebx+eax*4]
call putpixel
pop eax
cmp edi, [esp]
loopnz .loopii
jnz .loopi
pop edi
sub edi, [delta]
call align_input
dec edx
jnz convert1
ret ret
convertno32: align_input:
mov ebx,I_END
add ebx, [I_END+14]
add ebx,14 ;start of color table
push esi push esi
add esi,[bps] sub esi, I_END
mov [eos],esi sub esi, [I_END+10]
neg esi
and esi, 3
add [esp], esi
pop esi pop esi
nextelem: ret
putpixel:
push eax push eax
movzx eax,byte [esi] stosw
cmp word [I_END+28],4 shr eax, 16
je convert4bpp stosb
cmp word [I_END+28],1
je convert1bpp
call converttable
convert2:
pop eax pop eax
inc esi
cmp esi,[eos]
jae convert1
add edi,3
jmp nextelem
convert4bpp:
shl ax,4
shr al,4
push ax
movzx eax,ah
call converttable
add edi,3
pop ax
movzx eax,al
call converttable
jmp convert2
convert1bpp:
mov ecx,eax
mov edx,7
nextbit:
xor eax,eax
bt ecx,edx
jnc noaddelem
inc eax
noaddelem:
push edx
call converttable
pop edx
dec edx
cmp edx,0xffffffff
je convert2
add edi,3
jmp nextbit
converttable:
shl eax,2
add eax,ebx
mov edx, [eax]
mov dword [edi],edx
ret ret
; ********************************************* ; *********************************************
@ -440,24 +493,13 @@ draw_window:
; DATA AREA ; DATA AREA
labelt: labelt:
db 'MeView v.0.3' db 'MeView v.0.4'
lsz buttext,\ lsz buttext,\
en, ' FILE OPEN INFO BGRD',\ en, ' FILE OPEN INFO BGRD',\
ru, ' ”€‰‹ ŽŠ<E28099> ˆ<>”Ž ”Ž<E2809D> ',\ ru, ' ”€‰‹ ŽŠ<E28099> ˆ<>”Ž ”Ž<E2809D> ',\
de, 'DATEI OEFNEN INFO HGRD' de, 'DATEI OEFNEN INFO HGRD'
status dd 0 ;bit0=1 if file thread is created
bps dd 0
dwps dd 0
soi dd 0
sop dd 0
eop dd 0
eos dd 0
process dd 0
bWasDraw db 0
thread1: ; start of thread1 thread1: ; start of thread1
call draw_window1 call draw_window1
@ -967,6 +1009,12 @@ draw_window3:
; DATA AREA ; DATA AREA
status dd 0 ;bit0=1 if file thread is created
soi dd 0
delta dd 0
process dd 0
bWasDraw db 0
vflag: db 'x' vflag: db 'x'
bgrmode: dd 1 bgrmode: dd 1