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:
@ -259,125 +267,170 @@ load_image:
@@: @@:
ret ret
convert: convert:
movzx eax,word [I_END+28] mov ecx, I_END
mul dword [I_END+18] add ecx, [ecx+2]
; mov ebx,32 mov [soi], ecx
; div ebx mov ebp, [I_END+18]
; test edx,edx lea ebp, [ebp*3] ; ebp = size of output scanline
; je noaddword mov eax, [I_END+22]
; inc eax dec eax
; noaddword: mul ebp
add eax, 31 add eax, ecx
shr eax, 5 mov edi, eax ; edi points to last scanline
mov [dwps],eax ;dwps-doublewords per string mov esi, I_END
shl eax,2 add esi, [esi+10]
mov [bps],eax ;bps-bytes per string mov ebx, I_END+54
mov edx, [I_END+22]
cmp dword [I_END+34],0 lea eax, [ebp*2]
jne yespicsize ;if picture size is defined mov [delta], eax
mul dword [I_END+22] test edx, edx
mov dword [I_END+34],eax jz .ret
jns @f
yespicsize: neg edx
mov eax,I_END and [delta], 0
push eax mov edi, ecx
add eax, [I_END+2];file size @@:
inc eax movzx eax, word [I_END+28]
mov [soi],eax ;soi-start of image area for drawing cmp eax, 24
pop eax jz convert24
add eax, [I_END+10] cmp eax, 8
mov [sop],eax ;sop-start of picture in file jz convert8
add eax, [I_END+34] cmp eax, 4
mov [eop],eax ;eop-end of picture in file jz convert4
mov eax, [I_END+18] dec eax
mov ebx,3 jz convert1
mul ebx ;3x pixels in eax .ret:
ret
mov edi,[soi] ;initializing convert24:
mov esi,[eop] mov ecx, ebp
sub esi,[bps] rep movsb
sub edi, [delta]
mov eax, ebp
nextstring: neg eax
and eax, 3
add esi, eax
dec edx
jnz convert24
ret
convert8:
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