1) background image to the proportional stretching with cropping
2) optimize scaling.obj
3) scaling.obj and convert.obj support RAW header to all cases is now

git-svn-id: svn://kolibrios.org@2163 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Marat Zakiyanov (Mario79) 2011-09-07 16:34:44 +00:00
parent 48e49905d0
commit d250796055
8 changed files with 907 additions and 678 deletions

View File

@ -3,10 +3,10 @@
background: background:
cmp [soi],0 cmp [soi],0
je .end je .end
cmp [bgrmode],dword 2 cmp [bgrmode],dword 2
jbe @f ja .stretch_crop
jmp .end
@@:
mov ecx,[img_width] ; øèðèíà mov ecx,[img_width] ; øèðèíà
test ecx,ecx test ecx,ecx
jz .end jz .end
@ -24,20 +24,149 @@ background:
cmp [img_resolution],24 cmp [img_resolution],24
je @f je @f
push dword image_file push dword image_file
call [convert_Conv_24b] call [convert_Conv_24b]
mov ecx,[raw_pointer_2] mov ecx,[raw_pointer_2]
mcall 15,5 ;15,5 set data add ecx,44
mov ecx,[raw_pointer_2] mcall 15,5 ;15,5 set data
mcall 68,13 mcall 68,13,[raw_pointer_2]
jmp .set_mode jmp .set_mode
@@: @@:
mcall 15,5 ; 15,5 set data mcall 15,5 ; 15,5 set data
.set_mode: .set_mode:
mov ecx,[bgrmode] mcall 15,4,[bgrmode] ; 15,4 set mode
mcall 15,4 ; 15,4 set mode dec ebx ; 15,3 redraw background
dec ebx ; 15,3 redraw background
mcall mcall
.end: .end:
ret ret
;---------------------------------------------------------------------
.stretch_crop:
; cmp [bgrmode],dword 3
; jne .stretch_inscribe
xor eax,eax
mov [stretch_start_coordinates],eax
mcall 14
mov ebx,eax
and eax,0xffff
inc eax
mov [screen_high],eax
shr ebx,16
inc ebx
mov [screen_width],ebx
xchg eax,ebx
call calculate_relation
mov [screen_relation],eax
mov eax,[img_width]
mov ebx,[img_high]
call calculate_relation
mov [picture_relation],eax
cmp eax,[screen_relation]
jb @f
; Y = Yimg
; X = Yimg*Xscreen/Yscreen
mov eax,[img_high]
mov [stretch_img_high],eax
mov eax,[img_high]
imul eax,dword [screen_width]
mov ebx,[screen_high]
call integer_division
mov [stretch_img_width],eax
mov ebx,[img_width]
sub ebx,eax
shr ebx,1
mov [stretch_start_coordinates.x],bx
jmp .continue
@@:
; X = Ximg
; Y = Ximg*Yscreen/Xscreen
mov eax,[img_width]
mov [stretch_img_width],eax
mov eax,[img_width]
imul eax,dword [screen_high]
mov ebx,[screen_width]
call integer_division
mov [stretch_img_high],eax
mov ebx,[img_high]
sub ebx,eax
shr ebx,1
mov [stretch_start_coordinates.y],bx
.continue:
mov ebx,[screen_width]
shl ebx,16
add ebx,[screen_high]
mov eax,[stretch_img_width]
shl eax,16
add eax,[stretch_img_high]
push dword eax ; eax - crop size
push dword 0 ; edi - background color
push dword 1 ; esi - filtering
push dword 0 ; edx - scaling mode
push dword [stretch_start_coordinates] ; ecx - start_coordinates
push ebx ; ebx - new_size
push dword image_file ; eax - convert data table
call [Scaling_Start]
call background_1
ret
;---------------------------------------------------------------------
;.stretch_inscribe:
; ret
;---------------------------------------------------------------------
background_1:
mov ecx,[screen_width] ;[crop_img_width] ; øèðèíà
test ecx,ecx
jz .end
mov edx,[screen_high] ;[crop_img_high] ; âûñîòà 
test edx,edx
jz .end
mcall 15,1 ; set size
mov esi,ecx
imul esi,edx
lea esi,[esi*3]
mov ecx,[raw_pointer_2] ;[soi]
mov eax,[ecx+28]
add ecx,eax
xor edx,edx
mov eax,[raw_pointer_2]
mov eax,[eax+12] ;overall depth of the pixel
cmp al,24
je @f
mov eax,[raw_pointer_2]
mov [crop_raw_pointer],eax
push dword crop_image_file
call [convert_Conv_24b]
mov ecx,[crop_raw_pointer_2]
add ecx,44
mcall 15,5 ;15,5 set data
mcall 68,13,[crop_raw_pointer_2]
jmp .set_mode
@@:
mcall 15,5 ; 15,5 set data
.set_mode:
xor ecx,ecx
inc ecx
; mov ecx,[bgrmode]
mcall 15,4 ; 15,4 set mode
dec ebx ; 15,3 redraw background
mcall
.end:
mov ecx,[raw_pointer_2]
mcall 68,13
ret
;--------------------------------------------------------------------- ;---------------------------------------------------------------------

View File

@ -38,7 +38,7 @@ lsz fitext,\
db 0 db 0
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
Authors_text: Authors_text:
.1: db 'zSea version: 1.00 RC3 Date: 24/08/2011',0 .1: db 'zSea version: 1.00 RC4 Date: 07/09/2011',0
.2: db 'Authors:',0 .2: db 'Authors:',0
.3: db 'Marat Zakiyanov aka Mario(Mario79)',0 .3: db 'Marat Zakiyanov aka Mario(Mario79)',0
.4: db 'zSea program, modules: cnv_bmp.obj,',0 .4: db 'zSea program, modules: cnv_bmp.obj,',0
@ -198,6 +198,22 @@ zoom_factors:
dd 5000 dd 5000
zoom_factors_old dd 0 zoom_factors_old dd 0
;---------------------------------------------------------------------
; not change this section!!!
; start section
;---------------------------------------------------------------------
align 4
crop_image_file dd 0 ;+0
crop_raw_pointer dd 0 ;+4
crop_return_code dd 0 ;+8
crop_img_size dd 0 ;+12
crop_deflate_unpack dd 0 ;+16
crop_raw_pointer_2 dd 0 ;+20
;---------------------------------------------------------------------
; end section
;---------------------------------------------------------------------
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
; not change this section!!! ; not change this section!!!
; start section ; start section
@ -234,23 +250,36 @@ background_color dd 0xffffff
skin_height dd 0 skin_height dd 0
RAW1_pointer dd 0 screen_high dd 0
RAW1_size_x dd 0 screen_width dd 0
RAW1_size dd 0
Repeat_N dd 0 stretch_start_coordinates:
Total_Repeat_N dd 1 .y dw 0
.x dw 0
screen_relation dd 0
picture_relation dd 0
stretch_img_high dd 0
stretch_img_width dd 0
RAW1_pointer dd 0
RAW1_size_x dd 0
RAW1_size dd 0
Repeat_N dd 0
Total_Repeat_N dd 1
previous_frame_pointer dd 0 previous_frame_pointer dd 0
Animation_timer dd 0 Animation_timer dd 0
Frame_delay dw 0 Frame_delay dw 0
Transp_flag db 0 Transp_flag db 0
Transp_index db 0 Transp_index db 0
Disposal_Method db 0 Disposal_Method db 0
RAW1_flag db 0 RAW1_flag db 0
no_fill db 0 no_fill db 0
redraw_wallpaper_flag db 0 redraw_wallpaper_flag db 0
calc_next_value_plus db 0 calc_next_value_plus db 0
calc_next_value_minus db 0 calc_next_value_minus db 0
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 4 align 4
;plugin dd 0 ;plugin dd 0
@ -871,9 +900,9 @@ op_text:
.e1: .e1:
.2 db 'Stretch' .2 db 'Stretch'
.e2: .e2:
.3 db 'Stretch + V crop' .3 db 'Stretch + Crop'
.e3: .e3:
.4 db 'Stretch + H crop' .4 db 'Stretch + Inscribe'
.e4: .e4:
option_group1 dd op1 option_group1 dd op1

View File

@ -42,449 +42,448 @@ include '../../../../macros.inc'
START: START:
pushad pushad
mov eax,dword [esp+36] mov eax,dword [esp+36]
mov [pointer],eax mov [pointer],eax
mov eax,[eax+4] mov eax,[eax+4]
mov [image_file],eax mov [image_file],eax
mov esi,[eax+28] mov esi,[eax+28]
add esi,eax add esi,eax
mov edi,esi mov edi,esi
mov ecx,[eax+32] mov ecx,[eax+32]
; xor ebx,ebx
; mov [raw_area],ebx
; mov ebx,[pointer]
; movzx eax,word [eax+18]
; mov [ebx+24],eax
; jmp .ret_ok
cmp [eax+16],word 16 cmp [eax+16],word 16
je .16b je .16b
cmp [eax+12],dword 1 cmp [eax+12],dword 1
je .1b je .1b
cmp [eax+12],dword 2 cmp [eax+12],dword 2
je .2b je .2b
cmp [eax+12],dword 4 cmp [eax+12],dword 4
je .4b je .4b
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.ret_ok: .ret_ok:
; mov ebx,[pointer] mov ebx,[image_file]
; mov eax,[raw_area] cmp [ebx+18],word 2
; mov [ebx+20],eax ; store RAW pointer jne @f
; mov [ebx+24],ecx mov eax,[ebx+12]
shr eax,1
mov ebx,[image_file] mov [ebx+12],eax
cmp [ebx+18],word 2
jne @f
mov eax,[ebx+12]
shr eax,1
mov [ebx+12],eax
@@: @@:
popad popad
ret 4 ret 4
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.less_8b: .less_8b:
mov edx,[image_file] mov edx,[image_file]
mov ecx,[area_size] mov ecx,[area_size]
add ecx,[edx+28] add ecx,[edx+28]
mcall 68,20 mcall 68,20
mov [image_file],eax mov [image_file],eax
mov ecx,[area_size]
mov ecx,[area_size] mov eax,ecx
mov eax,ecx shr ecx,2
shr ecx,2 test eax,3
test eax,3 jz @f
jz @f inc ecx
inc ecx
@@: @@:
mov esi,[raw_area] mov esi,[raw_area]
mov edi,[image_file] mov edi,[image_file]
add edi,[edi+28] add edi,[edi+28]
cld cld
rep movsd rep movsd
mov ecx,[raw_area] mcall 68,13,[raw_area]
mcall 68,13 mov eax,[image_file]
mov eax,[image_file] mov ebx,[pointer]
mov ebx,[pointer] mov [ebx+4],eax
mov [ebx+4],eax
popad popad
ret 4 ret 4
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.16b: .16b:
cmp [eax+18],word 3 ; eax - RAW image_file
je @f ;.convert_16_in_8 cmp [eax+18],word 3
cmp [eax+18],word 4 je @f
jne .16b_1 cmp [eax+18],word 4
jne .16b_1
@@: @@:
xor ebx,ebx xor ebx,ebx
mov bx,[eax+18] mov bx,[eax+18]
xchg eax,ecx xchg eax,ecx
xor edx,edx xor edx,edx
div ebx div ebx
xchg ecx,eax xchg ecx,eax
shr ecx,1 shr ecx,1
mov [eax+16],word 8 mov [eax+16],word 8
mov ebx,[eax+12] mov ebx,[eax+12]
shr ebx,1 shr ebx,1
mov [eax+12],ebx mov [eax+12],ebx
mov ebx,eax mov ebx,eax
; jmp .ret_ok
.convert_16_in_8: ; converting 16 bit sample to 8 bit .convert_16_in_8: ; converting 16 bit sample to 8 bit
cld cld
lodsw lodsw
mov al,ah mov al,ah
stosb stosb
lodsw lodsw
mov al,ah mov al,ah
stosb stosb
lodsw lodsw
mov al,ah mov al,ah
stosb stosb
cmp [ebx+18],word 4 cmp [ebx+18],word 4
jne @f jne @f
lodsw lodsw
mov al,ah mov al,ah
stosb stosb
@@: @@:
dec ecx dec ecx
jnz .convert_16_in_8 jnz .convert_16_in_8
jmp .16b_end
jmp .16b_end
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.16b_1: .16b_1:
cmp [eax+18],word 1 ; eax - RAW image_file
je @f ;.convert_16_in_8_1 cmp [eax+18],word 1
cmp [eax+18],word 2 je @f
jne .16b_end cmp [eax+18],word 2
jne .16b_end
@@: @@:
shr ecx,1 shr ecx,1
mov [eax+16],word 8 mov [eax+16],word 8
mov ebx,[eax+12] mov ebx,[eax+12]
shr ebx,1 shr ebx,1
mov [eax+12],ebx mov [eax+12],ebx
.convert_16_in_8_1: .convert_16_in_8_1:
cld cld
lodsw lodsw
; shr ax,8
; mov al,ah
stosb stosb
dec ecx dec ecx
jnz .convert_16_in_8_1 jnz .convert_16_in_8_1
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.16b_end: .16b_end:
xor eax,eax xor eax,eax
mov [raw_area],eax mov [raw_area],eax
jmp .ret_ok jmp .ret_ok
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.4b: .4b:
call .get_memory call .get_memory
mov edx,ebx mov edx,ebx
inc ebx inc ebx
shr ebx,1 shr ebx,1
.4b_1: .4b_1:
push ebx edi push ebx edi
@@: @@:
cld cld
lodsb lodsb
shl eax,8 shl eax,8
mov al,ah mov al,ah
and ah,0xf and ah,0xf
shr al,4 shr al,4
stosw stosw
dec ebx dec ebx
jnz @b jnz @b
pop edi ebx pop edi ebx
add edi,edx add edi,edx
dec ecx dec ecx
jnz .4b_1 jnz .4b_1
jmp .less_8b ;.ret_ok jmp .less_8b
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.2b: .2b:
call .get_memory call .get_memory
; jmp .ret_ok mov edx,ebx
; shr ecx,1 mov eax,ebx
mov edx,ebx shr ebx,2
mov eax,ebx test eax,3
shr ebx,2 jz @f
test eax,3 inc ebx
jz @f
inc ebx
@@: @@:
mov ebp,ebx mov ebp,ebx
.2b_1: .2b_1:
push ebp edi push ebp edi
@@: @@:
cld cld
lodsb lodsb
mov bl,al mov bl,al
and al,11b and al,11b
shl ax,8 shl ax,8
mov al,bl mov al,bl
shr al,2 shr al,2
and al,11b and al,11b
shl eax,8 shl eax,8
mov al,bl mov al,bl
shr al,4 shr al,4
and al,11b and al,11b
shl eax,8 shl eax,8
mov al,bl mov al,bl
shr al,6 shr al,6
and al,11b and al,11b
stosd stosd
dec ebp dec ebp
jnz @b jnz @b
pop edi ebp pop edi ebp
add edi,edx add edi,edx
dec ecx dec ecx
jnz .2b_1 jnz .2b_1
jmp .less_8b ;.ret_ok jmp .less_8b
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.1b: .1b:
call .get_memory call .get_memory
mov edx,ebx mov edx,ebx
mov eax,ebx mov eax,ebx
shr ebx,3 shr ebx,3
test eax,7 test eax,7
jz @f jz @f
inc ebx inc ebx
@@: @@:
mov ebp,ebx mov ebp,ebx
.1b_1: .1b_1:
push ebp edi push ebp edi
@@: @@:
cld cld
lodsb lodsb
mov bl,al mov bl,al
shr al,4 shr al,4
and al,1b and al,1b
shl ax,8 shl ax,8
mov al,bl mov al,bl
shr al,5 shr al,5
and al,1b and al,1b
shl eax,8 shl eax,8
mov al,bl mov al,bl
shr al,6 shr al,6
and al,1b and al,1b
shl eax,8 shl eax,8
mov al,bl mov al,bl
shr al,7 shr al,7
; and al,1b
; shl eax,8
stosd stosd
mov al,bl mov al,bl
and al,1b and al,1b
shl ax,8 shl ax,8
mov al,bl mov al,bl
shr al,1 shr al,1
and al,1b and al,1b
shl eax,8 shl eax,8
mov al,bl mov al,bl
shr al,2 shr al,2
and al,1b and al,1b
shl eax,8 shl eax,8
mov al,bl mov al,bl
shr al,3 shr al,3
and al,1b and al,1b
stosd stosd
dec ebp dec ebp
jnz @b jnz @b
pop edi ebp pop edi ebp
add edi,edx add edi,edx
dec ecx dec ecx
jnz .1b_1 jnz .1b_1
jmp .less_8b ;.ret_ok
jmp .less_8b
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.get_memory: .get_memory:
mov ebx,dword 8 ; eax - RAW image_file
mov [eax+16],bx mov ebx,dword 8
mov [eax+12],ebx mov [eax+16],bx
; mov esi,[eax+28] mov [eax+12],ebx
; add esi,eax mov ecx,[eax+4]
; push ecx imul ecx,[eax+8]
mov ecx,[eax+4] push eax
imul ecx,[eax+8] mov [area_size],ecx
push eax mcall 68,12
mov [area_size],ecx mov [raw_area],eax
mcall 68,12 mov edi,eax
; pop ecx pop eax
mov [raw_area],eax mov ebx,[eax+4]
mov edi,eax mov ecx,[eax+8]
pop eax
mov ebx,[eax+4]
mov ecx,[eax+8]
ret ret
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
Convert24b: Convert24b:
pushad pushad
mov eax,dword [esp+36] mov eax,dword [esp+36]
mov [pointer],eax mov [pointer],eax
mov eax,[eax+4] mov eax,[eax+4]
mov [image_file],eax mov [image_file],eax
mov esi,[eax+28] mov esi,[eax+28]
add esi,eax add esi,eax
mov ebp,[eax+20] mov ebp,[eax+20]
add ebp,eax add ebp,eax
mov ecx,[eax+4] mov ecx,[eax+4]
imul ecx,[eax+8] imul ecx,[eax+8]
push eax ecx push eax ecx
lea ecx,[ecx*3] lea ecx,[ecx*3]
mcall 68,12 mov edx,ecx
mov [raw_area],eax add ecx,44 ; header
mov edi,eax mcall 68,12 ;get new RAW area
pop ecx eax mov [raw_area],eax
mov edi,eax
push esi
mov esi,[image_file]
mov ecx,3
cld
rep movsd ;copy the 3 first dword for the structure of RAW
pop esi
sub edi,12
mov [edi+12],dword 24 ;overall depth of the pixel
mov [edi+16],word 8 ;channel depth of the pixel
xor eax,eax
mov [edi+20],eax ;palette area pointer
mov [edi+24],eax ;palette area size
mov [edi+28],dword 44 ;rgb area pointer
mov [edi+32],edx ;rgb area size
mov [edi+36],eax ;transparency area pointer
mov [edi+40],eax ;transparency area size
pop ecx eax
add edi,44
cmp [eax+12],dword 32 cmp [eax+12],dword 32
je .32b je .32b
cmp [eax+12],dword 16 cmp [eax+12],dword 16
je .16b je .16b
cmp [eax+12],dword 15 cmp [eax+12],dword 15
je .15b je .15b
cmp [eax+12],dword 8 cmp [eax+12],dword 8
je .8b je .8b
.ret_ok: .ret_ok:
mov ebx,[pointer] mov ebx,[pointer]
mov eax,[raw_area] mov eax,[raw_area]
mov [ebx+20],eax ; store RAW pointer mov [ebx+20],eax ; store RAW pointer
popad popad
ret 4 ret 4
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.32b: .32b:
cld cld
lodsd lodsd
stosw stosw
shr eax,16 shr eax,16
stosb stosb
dec ecx dec ecx
jnz .32b jnz .32b
jmp .ret_ok jmp .ret_ok
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.16b: .16b:
cld cld
lodsw lodsw
xor ebx,ebx xor ebx,ebx
ror ax,11 ror ax,11
mov bl,al mov bl,al
and bl,11111b and bl,11111b
shl bl,3 shl bl,3
shl ebx,8 shl ebx,8
rol ax,6 rol ax,6
mov bl,al mov bl,al
and bl,111111b and bl,111111b
shl bl,2 shl bl,2
shl ebx,8 shl ebx,8
rol ax,5 rol ax,5
mov bl,al mov bl,al
and bl,11111b and bl,11111b
shl bl,3 shl bl,3
mov eax,ebx mov eax,ebx
cld cld
stosw stosw
shr eax,16 shr eax,16
stosb stosb
dec ecx dec ecx
jnz .16b jnz .16b
jmp .ret_ok jmp .ret_ok
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.15b: .15b:
cld cld
lodsw lodsw
xor ebx,ebx xor ebx,ebx
ror ax,10 ror ax,10
mov bl,al mov bl,al
and bl,11111b and bl,11111b
shl bl,3 shl bl,3
shl ebx,8 shl ebx,8
rol ax,5 rol ax,5
mov bl,al mov bl,al
and bl,11111b and bl,11111b
shl bl,3 shl bl,3
shl ebx,8 shl ebx,8
rol ax,5 rol ax,5
mov bl,al mov bl,al
and bl,11111b and bl,11111b
shl bl,3 shl bl,3
mov eax,ebx mov eax,ebx
cld cld
stosw stosw
shr eax,16 shr eax,16
stosb stosb
dec ecx dec ecx
jnz .15b jnz .15b
jmp .ret_ok jmp .ret_ok
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.8b: .8b:
xor eax,eax xor eax,eax
cld cld
lodsb lodsb
shl eax,2 shl eax,2
mov eax,[eax+ebp] mov eax,[eax+ebp]
cld cld
stosw stosw
shr eax,16 shr eax,16
stosb stosb
dec ecx dec ecx
jnz .8b jnz .8b
jmp .ret_ok jmp .ret_ok
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 16 align 16
EXPORTS: EXPORTS:
dd szStart, START dd szStart, START
dd szVersion, 0x00010002 dd szVersion, 0x00010003
dd szConv_24b, Convert24b dd szConv_24b, Convert24b
dd 0 dd 0
szStart db 'START',0 szStart db 'START',0
szVersion db 'version',0 szVersion db 'version',0

View File

@ -38,220 +38,215 @@ include '../../../../macros.inc'
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
START: START:
pushad pushad
mov edi,dword [esp+56] mov eax,dword [esp+60] ; eax - crop size
mov esi,dword [esp+52] mov ebx,eax
mov edx,dword [esp+48] and eax,0xffff
mov ecx,dword [esp+44] shr ebx,16
mov ebx,dword [esp+40] mov [crop_x],ebx
mov eax,dword [esp+36] mov [crop_y],eax
mov [pointer],eax mov edi,dword [esp+56] ; edi - background color
test bx,bx mov esi,dword [esp+52] ; esi - filtering
jnz @f mov edx,dword [esp+48] ; edx - scaling mode
inc bx mov ecx,dword [esp+44] ; ecx - start_coordinates
mov ebx,dword [esp+40] ; ebx - new_size
mov eax,dword [esp+36] ; eax - convert data table
mov [pointer],eax
test bx,bx
jnz @f
inc bx
@@: @@:
ror ebx,16 ror ebx,16
test bx,bx test bx,bx
jnz @f jnz @f
inc bx
inc bx
@@: @@:
rol ebx,16 rol ebx,16
mov [new_size],ebx mov [new_size],ebx
mov [start_coordinates],ecx mov [start_coordinates],ecx
mov [scaling_mode],edx mov [scaling_mode],edx
mov [filtering],esi mov [filtering],esi
mov [background_color],edi mov [background_color],edi
mov eax,[eax+4] mov eax,[eax+4]
mov [image_file],eax mov [image_file],eax
mov esi,[eax+28] mov esi,[eax+28]
add esi,eax add esi,eax
mov ebx,[eax+20] mov ebx,[eax+20]
add ebx,eax add ebx,eax
mov [palette],ebx mov [palette],ebx
mov ebx,[eax+12] mov ebx,[eax+12]
mov [resolution],ebx mov [resolution],ebx
cmp ebx,32 cmp ebx,32
jne @f jne @f
mov ebp,dword START.32 mov ebp,dword START.32
jmp .1 jmp .1
@@: @@:
cmp ebx,24 cmp ebx,24
jne @f jne @f
mov ebp,dword START.24 mov ebp,dword START.24
jmp .1 jmp .1
@@: @@:
cmp ebx,16 cmp ebx,16
jne @f jne @f
mov ebp,dword START.16 mov ebp,dword START.16
jmp .1 jmp .1
@@: @@:
cmp ebx,15 cmp ebx,15
jne @f jne @f
inc ebx inc ebx
mov ebp,dword START.16 mov ebp,dword START.16
jmp .1 jmp .1
@@: @@:
cmp ebx,8 cmp ebx,8
jne @f jne @f
mov ebp,dword START.8 mov ebp,dword START.8
@@: @@:
.1: .1:
shr ebx,3 shr ebx,3
mov [bytes_to_pixel],ebx mov [bytes_to_pixel],ebx
mov ebx,[eax+8] mov ebx,[eax+8]
mov [y],ebx mov [y],ebx
mov ebx,[eax+4] mov ebx,[eax+4]
mov [x],ebx mov [x],ebx
imul ebx,[bytes_to_pixel] imul ebx,[bytes_to_pixel]
mov [size_x],ebx mov [size_x],ebx
mov eax,100 mov eax,[crop_y]
shl eax,12 test eax,eax
mov ebx,[scaling_mode] jz @f
test ebx,ebx mov [y],eax
jnz @f
inc ebx
@@: @@:
xor edx,edx mov eax,[crop_x]
div ebx test eax,eax
mov [scaling_delta],eax jz @f
mov [x],eax
call .get_memory
cmp [scaling_mode],0
jne @f
call .scaling
jmp .ret_ok
@@: @@:
call .scaling_2 mov eax,100
shl eax,12
mov ebx,[scaling_mode]
test ebx,ebx
jnz @f
inc ebx
@@:
xor edx,edx
div ebx
mov [scaling_delta],eax
call .get_memory
call .scaling
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.ret_ok: .ret_ok:
mcall 68,13,[area_for_x] mcall 68,13,[area_for_x]
mov ebx,[pointer] mov ebx,[pointer]
mov eax,[raw_area] mov eax,[raw_area]
mov [ebx+20],eax ; store RAW pointer mov [ebx+20],eax ; store RAW pointer
; movzx eax,word [new_size.x1] ; movzx eax,word [new_size.x1]
; mov [ebx+24],esi ;eax ; mov [ebx+24],esi ;eax
; movzx eax,word [new_size.y1] ; movzx eax,word [new_size.y1]
; mov [ebx+28],eax ; mov [ebx+28],eax
; mov eax,[size_x] ; mov eax,[size_x]
; mov [ebx+32],eax ; mov [ebx+32],eax
; mov eax,[bytes_to_pixel] ; mov eax,[bytes_to_pixel]
; mov [ebx+36],eax ; mov [ebx+36],eax
; mov eax,[x] ; mov eax,[x]
; mov [ebx+40],eax ; mov [ebx+40],eax
; mov eax,[y] ; mov eax,[y]
; mov [ebx+44],eax ; mov [ebx+44],eax
.exit: .exit:
popad popad
ret 24 ret 28
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 4 align 4
.scaling: .scaling:
xor ecx,ecx xor eax,eax
.y: mov ax,[start_coordinates.y]
xor ebx,ebx imul eax,[size_x]
;------------------------- add esi,eax
.x: xor eax,eax
call ebp mov ax,[start_coordinates.x]
inc ebx imul eax,[bytes_to_pixel]
cmp bx,[new_size.x1] add esi,eax
jb .x
;-------------------------
inc ecx
cmp cx,[new_size.y1]
jb .y
ret
;---------------------------------------------------------------------
align 4
.scaling_2:
xor eax,eax
mov ax,[start_coordinates.y]
imul eax,[size_x]
add esi,eax
xor eax,eax
mov ax,[start_coordinates.x]
imul eax,[bytes_to_pixel]
add esi,eax
xor eax,eax xor eax,eax
dec eax dec eax
mov [temp_y],eax mov [temp_y],eax
xor ecx,ecx xor ecx,ecx
align 4 align 4
.y_2: .y_2:
xor ebx,ebx xor ebx,ebx
;------------------------- ;-------------------------
align 4 align 4
.x_2: .x_2:
call ebp call ebp
inc ebx inc ebx
cmp bx,[new_size.x1] cmp bx,[new_size.x1]
jb .x_2 jb .x_2
;------------------------- ;-------------------------
inc ecx inc ecx
cmp cx,[new_size.y1] cmp cx,[new_size.y1]
jb .y_2 jb .y_2
ret ret
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 4 align 4
.32: .32:
push ecx ebx push ecx ebx
call .calculate_pixel call .calculate_pixel
mov eax,[ecx] mov eax,[ecx]
call .check_filtering_32 call .check_filtering_32
pop ebx ecx pop ebx ecx
cld cld
stosd stosd
ret ret
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 4 align 4
.24: .24:
push ecx ebx push ecx ebx
call .calculate_pixel call .calculate_pixel
mov eax,[ecx] mov eax,[ecx]
call .check_filtering_24 call .check_filtering_24
cld cld
stosw stosw
shr eax,16 shr eax,16
pop ebx ecx pop ebx ecx
cld cld
stosb stosb
ret ret
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 4 align 4
.16: .16:
push ecx ebx push ecx ebx
call .calculate_pixel call .calculate_pixel
xor eax,eax xor eax,eax
mov ax,[ecx] mov ax,[ecx]
call .check_filtering_16 call .check_filtering_16
pop ebx ecx pop ebx ecx
cld cld
stosw stosw
ret ret
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 4 align 4
.8: .8:
push ecx ebx push ecx ebx
call .calculate_pixel call .calculate_pixel
cmp [filtering],0 cmp [filtering],0
jne @f jne @f
mov al,[ecx] mov al,[ecx]
pop ebx ecx pop ebx ecx
cld cld
stosb stosb
ret ret
@@: @@:
call .check_filtering_8 call .check_filtering_8
cld cld
stosw stosw
shr eax,16 shr eax,16
pop ebx ecx pop ebx ecx
cld cld
stosb stosb
ret ret
@ -259,181 +254,240 @@ align 4
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 4 align 4
.calculate_pixel: .calculate_pixel:
test ecx,ecx test ecx,ecx
jz .offset_x jz .offset_x
;.offset_y: ;.offset_y:
mov eax,ecx mov eax,ecx
mov ecx,[temp_y] mov ecx,[temp_y]
cmp eax,ecx cmp eax,ecx
jne .new_y jne .new_y
mov eax,[temp_y_offset] mov eax,[temp_y_offset]
mov ecx,eax mov ecx,eax
jmp .offset_x jmp .offset_x
;-------------------------------- ;--------------------------------
align 4 align 4
.new_y: .new_y:
mov [temp_y],eax mov [temp_y],eax
mov ebx,[scaling_mode]
mov ebx,[scaling_mode] test ebx,ebx
test ebx,ebx jz @f
jz @f
imul eax,[scaling_delta] imul eax,[scaling_delta]
;-------------------------------- ;--------------------------------
push ebx push ebx
mov ebx,eax mov ebx,eax
shr eax,12 shr eax,12
and ebx,0xFFF and ebx,0xFFF
shl ebx,7 ;multiply 128 shl ebx,7 ;multiply 128
shr ebx,12 shr ebx,12
mov [next_pixel_y],ebx mov [next_pixel_y],ebx
pop ebx pop ebx
;--------------------------------
jmp .ex_1
;-------------------------------- ;--------------------------------
jmp .ex_1
align 4 align 4
@@: @@:
imul eax,dword [y]
;-------------------------------- ;--------------------------------
imul eax,dword [y] align 4
mov bx,word [new_size.y1] @@:
mov bx,word [new_size.y1]
;-------------------------------- ;--------------------------------
align 4 align 4
.y_div: .y_div:
test ebx,ebx test ebx,ebx
jnz @f jnz @f
inc ebx inc ebx
;--------------------------------
align 4 align 4
@@: @@:
xor edx,edx xor edx,edx
div ebx div ebx
;-------------------------------- ;--------------------------------
push eax push eax
mov eax,edx mov eax,edx
shl eax,7 ;multiply 128 shl eax,7 ;multiply 128
xor edx,edx xor edx,edx
div ebx div ebx
mov [next_pixel_y],eax mov [next_pixel_y],eax
pop eax pop eax
;-------------------------------- ;--------------------------------
align 4 align 4
.ex_1: .ex_1:
mov [temp_y1],eax mov [temp_y1],eax
imul eax,[size_x] imul eax,[size_x]
mov [temp_y_offset],eax mov [temp_y_offset],eax
mov ecx,eax mov ecx,eax
align 4 align 4
.offset_x: .offset_x:
test ebx,ebx test ebx,ebx
jz .finish jz .finish
mov eax,[esp+4] ;ebx mov eax,[esp+4] ;ebx
mov edx,[esp+8] mov edx,[esp+8]
test edx,edx test edx,edx
jz .continue jz .continue
shl eax,3 shl eax,3
add eax,[area_for_x] add eax,[area_for_x]
mov edx,[eax+4] mov edx,[eax+4]
mov [next_pixel_x],edx mov [next_pixel_x],edx
mov eax,[eax] mov eax,[eax]
jmp .ex_3 jmp .ex_3
;-------------------------------- ;--------------------------------
align 4 align 4
.continue: .continue:
mov ebx,[scaling_mode] mov ebx,[scaling_mode]
test ebx,ebx test ebx,ebx
jz @f jz @f
imul eax,[scaling_delta] imul eax,[scaling_delta]
;-------------------------------- ;--------------------------------
mov ebx,eax mov ebx,eax
shr eax,12 shr eax,12
and ebx,0xFFF and ebx,0xFFF
shl ebx,7 ;multiply 128 shl ebx,7 ;multiply 128
shr ebx,12 shr ebx,12
mov [next_pixel_x],ebx mov [next_pixel_x],ebx
;-------------------------------- ;--------------------------------
jmp .ex_2 jmp .ex_2
;-------------------------------- ;--------------------------------
align 4 align 4
@@: @@:
imul eax,dword [x] imul eax,dword [x]
mov bx,word [new_size.x1] ;--------------------------------
align 4
@@:
mov bx,word [new_size.x1]
;-------------------------------- ;--------------------------------
align 4 align 4
.x_div: .x_div:
test ebx,ebx test ebx,ebx
jnz @f jnz @f
inc ebx inc ebx
align 4 align 4
@@: @@:
xor edx,edx xor edx,edx
div ebx div ebx
;-------------------------------- ;--------------------------------
push eax push eax
mov eax,edx mov eax,edx
shl eax,7 ;multiply 128 shl eax,7 ;multiply 128
xor edx,edx xor edx,edx
div ebx div ebx
mov [next_pixel_x],eax mov [next_pixel_x],eax
pop eax pop eax
;-------------------------------- ;--------------------------------
align 4 align 4
.ex_2: .ex_2:
mov edx,[bytes_to_pixel] mov edx,[bytes_to_pixel]
mov ebx,eax mov ebx,eax
xor eax,eax xor eax,eax
align 4 align 4
@@: @@:
add eax,ebx add eax,ebx
dec edx dec edx
jnz @r jnz @r
mov ebx,[esp+4] mov ebx,[esp+4]
shl ebx,3 shl ebx,3
add ebx,[area_for_x] add ebx,[area_for_x]
mov [ebx],eax mov [ebx],eax
mov edx,[next_pixel_x] mov edx,[next_pixel_x]
mov [ebx+4],edx mov [ebx+4],edx
align 4 align 4
.ex_3: .ex_3:
mov [temp_x1],eax mov [temp_x1],eax
add ecx,eax add ecx,eax
align 4 align 4
.finish: .finish:
add ecx,esi add ecx,esi
ret ret
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 4 align 4
.get_memory: .get_memory:
xor ecx,ecx
xor ecx,ecx mov cx,[new_size.x1]
mov cx,[new_size.x1] shl ecx,3
shl ecx,3 mcall 68,12
mcall 68,12 mov [area_for_x],eax
mov [area_for_x],eax
xor ecx,ecx xor ecx,ecx
mov ebx,[new_size] mov ebx,[new_size]
mov cx,bx mov cx,bx
shr ebx,16 shr ebx,16
imul ecx,ebx ;[eax+8] imul ecx,ebx ;[eax+8]
mov eax,[bytes_to_pixel] mov eax,[bytes_to_pixel]
cmp eax,1 cmp eax,1
jne @f jne @f
mov eax,3 mov eax,3
@@: @@:
imul ecx,eax imul ecx,eax
mcall 68,12 mov edx,ecx
mov [raw_area],eax add ecx,44
mov edi,eax mov eax,[image_file]
add ecx,[eax+24] ;palette area size
mcall 68,12
mov [raw_area],eax
mov edi,eax
; create RAW header
push esi
mov esi,[image_file]
mov ecx,44/4
cld
rep movsd ;copy the 3 first dword for the structure of RAW
mov edi,[raw_area]
movzx eax,word [new_size.x1]
mov [edi+4],eax
movzx eax,word [new_size.y1]
mov [edi+8],eax
mov [edi+32],edx ;rgb area size
xor eax,eax
mov [edi+36],eax ;transparency area pointer
mov [edi+40],eax ;transparency area size
cmp [filtering],eax ;0 or 1
je @f
mov [edi+20],eax ;palette area pointer
mov [edi+24],eax ;palette area size
mov [edi+28],dword 44 ;rgb area pointer
cmp [edi+12],dword 8 ;overall depth of the pixel
ja .not_overall_depth_8
mov [edi+12],dword 24 ;overall depth of the pixel
mov [edi+16],word 8 ;channel depth of the pixel
.not_overall_depth_8:
add edi,44
jmp .end
@@:
mov eax,[edi+24]
add edi,44
test eax,eax ;palette area is present?
jz @f
sub esi,44
mov ecx,[esi+24]
shr ecx,2
add esi,[esi+20]
cld
rep movsd ;copy palette area
@@:
.end:
pop esi
ret ret
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
include 'b_filter.inc' include 'b_filter.inc'
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 4 align 4
EXPORTS: EXPORTS:
dd szStart, START dd szStart, START
dd szVersion, 0x00010002 dd szVersion, 0x00010003
dd 0 dd 0
szStart db 'START',0 szStart db 'START',0
szVersion db 'version',0 szVersion db 'version',0
@ -442,14 +496,17 @@ align 4
pointer dd 0 pointer dd 0
image_file dd 0 image_file dd 0
new_size: new_size:
.y1: dw 0 .y1: dw 0
.x1: dw 0 .x1: dw 0
x: dd 0 x: dd 0
y: dd 0 y: dd 0
crop_x dd 0
crop_y dd 0
size_x dd 0 size_x dd 0
bytes_to_pixel dd 0 bytes_to_pixel dd 0
start_coordinates: start_coordinates:
.y dw 0 .y dw 0
@ -457,31 +514,31 @@ start_coordinates:
scaling_mode dd 0 scaling_mode dd 0
raw_area dd 0 raw_area dd 0
scaling_delta dd 0 scaling_delta dd 0
area_for_x dd 0 area_for_x dd 0
temp_y dd 0 temp_y dd 0
temp_y_offset dd 0 temp_y_offset dd 0
resolution dd 0 resolution dd 0
filtering dd 0 filtering dd 0
next_pixel_y dd 0 next_pixel_y dd 0
next_pixel_x dd 0 next_pixel_x dd 0
temp_y1 dd 0 temp_y1 dd 0
temp_x1 dd 0 temp_x1 dd 0
B_sample dd 0 B_sample dd 0
G_sample dd 0 G_sample dd 0
R_sample dd 0 R_sample dd 0
B_sample_1 dd 0 B_sample_1 dd 0
G_sample_1 dd 0 G_sample_1 dd 0
R_sample_1 dd 0 R_sample_1 dd 0
palette dd 0 palette dd 0
background_color dd 0 background_color dd 0

View File

@ -44,9 +44,23 @@ thread4: ; start of bgrd thread
jmp .still jmp .still
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
@@: @@:
cmp [option_group1],op2
jne @f
mov [bgrmode],dword 2 mov [bgrmode],dword 2
jmp .still jmp .still
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
@@:
cmp [option_group1],op3
jne @f
mov [bgrmode],dword 3
jmp .still
;---------------------------------------------------------------------
@@:
; cmp [option_group1],op4
; jne .still
mov [bgrmode],dword 4
jmp .still
;---------------------------------------------------------------------
.key: .key:
mcall mcall
cmp ah,27 cmp ah,27

View File

@ -77,6 +77,7 @@ thread2: ; start of info thread
add edx,10 add edx,10
mcall ,,[Total_Repeat_N] mcall ,,[Total_Repeat_N]
; mcall 47,0x80000,[PID2],<200, 5>,0xffffff ; mcall 47,0x80000,[PID2],<200, 5>,0xffffff
; mcall 47,0x800a0000,[error_locate],<140,5>,0x10ffffff ; mcall 47,0x800a0000,[error_locate],<140,5>,0x10ffffff
mcall 12,2 mcall 12,2

View File

@ -25,7 +25,7 @@
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;***************************************************************************** ;*****************************************************************************
; v.1.0 rń3 24.08.2011 ; v.1.0 rń4 07.09.2011
;****************************************************************************** ;******************************************************************************
use32 use32
org 0x0 org 0x0

View File

@ -40,11 +40,11 @@ rotate_counter_clockwise:
push dword image_file push dword image_file
; call [plugin_rotate] ; call [plugin_rotate]
call [rotate_Start] call [rotate_Start]
mov ebx,[raw_pointer] mov ebx,[raw_pointer]
mov eax,[ebx+4] mov eax,[ebx+4]
mov [img_width],eax mov [img_width],eax
mov eax,[ebx+8] mov eax,[ebx+8]
mov [img_high],eax mov [img_high],eax
call convert.img_resolution_ok call convert.img_resolution_ok
jmp kopen.1 jmp kopen.1
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
@ -67,10 +67,6 @@ no_scaling:
mov [zoom_factors],dword zoom_factors.100 mov [zoom_factors],dword zoom_factors.100
mov eax,[eax] mov eax,[eax]
jmp zoom_plus.2 jmp zoom_plus.2
; call calculate_arrows_offset
; call draw_zoom_factors
; jmp red
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
scaling: scaling:
mov eax,[soi] mov eax,[soi]
@ -114,10 +110,6 @@ scaling:
.fill_for_L_R: .fill_for_L_R:
cmp [no_fill],1 cmp [no_fill],1
je @f je @f
; xor eax,eax
; mov [no_fill],al
; ret
;@@:
pusha pusha
mov ebx,[image_start_coordinates] mov ebx,[image_start_coordinates]
mov ecx,ebx mov ecx,ebx
@ -130,7 +122,6 @@ scaling:
add bx,ax add bx,ax
add bx,[wa_width_2] add bx,[wa_width_2]
mov ax,[wa_width_1] mov ax,[wa_width_1]
; add ax,5
sub ax,bx sub ax,bx
rol ebx,16 rol ebx,16
mov bx,ax mov bx,ax
@ -142,10 +133,6 @@ scaling:
.fill_for_U_D: .fill_for_U_D:
cmp [no_fill],1 cmp [no_fill],1
je @f je @f
; xor eax,eax
; mov [no_fill],al
; ret
;@@:
pusha pusha
mov ebx,[image_start_coordinates] mov ebx,[image_start_coordinates]
mov ecx,ebx mov ecx,ebx
@ -222,13 +209,14 @@ scaling:
movzx esi,byte [filtering_flag] movzx esi,byte [filtering_flag]
; mov edi,[background_color] ; mov edi,[background_color]
push dword [background_color] ;edi - background color push dword 0 ; eax - crop size
push esi ; esi - filtering push dword [background_color] ; edi - background color
push dword [scaling_mode] ;edx - scaling mode push esi ; esi - filtering
push ecx ; ecx - start_coordinates push dword [scaling_mode] ; edx - scaling mode
push ebx ; ebx - new_size push ecx ; ecx - start_coordinates
push dword image_file ;eax - convert data table push ebx ; ebx - new_size
push dword image_file ; eax - convert data table
; pusha ; pusha
; mcall 26,9 ; mcall 26,9
; mov [test1],eax ; mov [test1],eax
@ -255,16 +243,16 @@ scaling:
mov edx,[image_start_coordinates] mov edx,[image_start_coordinates]
mov eax,edx mov eax,edx
shl eax,16 shl eax,16
mov ax,cx mov ax,cx
mov [scroll_bar_data_vertical.y],eax mov [scroll_bar_data_vertical.y],eax
mov eax,edx mov eax,edx
mov ebx,ecx mov ebx,ecx
shr ebx,16 shr ebx,16
mov ax,bx mov ax,bx
mov [scroll_bar_data_horizontal.x],eax mov [scroll_bar_data_horizontal.x],eax
; call correct_cur_area ; call correct_cur_area
@ -297,18 +285,24 @@ scaling:
add edx,eax add edx,eax
call .fill_for_U_D call .fill_for_U_D
@@: @@:
mov esi,[img_resolution] ; mov esi,[img_resolution]
cmp [img_resolution_2],15 ; cmp [img_resolution_2],15
jne @f ; jne @f
mov esi,15 ; mov esi,15
@@: ;@@:
mov eax,[raw_pointer_2]
mov esi,[eax+12]
mov eax,[raw_pointer] mov eax,[raw_pointer]
mov edi,[eax+20] mov edi,[eax+20]
add edi,eax add edi,eax
; mov edi,[img_palette] ; mov edi,[img_palette]
xor ebp,ebp xor ebp,ebp
mov ebx,[raw_pointer_2] mov ebx,[raw_pointer_2]
mov eax,[ebx+28]
add ebx,eax
mov eax,ecx mov eax,ecx
test ax,ax test ax,ax
@ -316,13 +310,13 @@ scaling:
shr eax,16 shr eax,16
test eax,eax test eax,eax
jz .no_draw ;@f jz .no_draw ;@f
cmp [filtering_flag],0 ; cmp [filtering_flag],0
je @f ; je @f
cmp esi,8 ; cmp esi,8
jne @f ; jne @f
mov esi,24 ; mov esi,24
@@: ;@@:
mcall 65 mcall 65
.no_draw: .no_draw:
; mov eax,ecx ; mov eax,ecx
@ -341,36 +335,42 @@ scaling:
; and eax,0xffff ; and eax,0xffff
; mov [test4],eax ; mov [test4],eax
push ebx
call draw_file_name_to_work_area call draw_file_name_to_work_area
pop ebx mcall 68,13,[raw_pointer_2]
mov ecx,ebx ;[raw_pointer_2]
mcall 68,13
xor eax,eax xor eax,eax
mov ax,[wa_width_2] mov ax,[wa_width_2]
; imul eax,100
; ÅÀÕ = ÅÀÕ * 100
shl eax,2 ; óìíîæåíèå íà 4
lea eax,[eax+eax*4] ; óìíîæåíèå íà 5
lea eax,[eax+eax*4] ; óìíîæåíèå íà 5
mov ebx,[img_width] mov ebx,[img_width]
test ebx,ebx ; imul eax,100
jnz @f call calculate_relation
inc ebx
@@:
xor edx,edx
div ebx
shl edx,1
cmp ebx,edx
jb @f
inc eax
@@:
mov [zoom_auto_factor],eax mov [zoom_auto_factor],eax
ret ret
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
calculate_relation:
; relation = X*100/Y
; eax = eax*100/ebx
; ÅÀÕ = ÅÀÕ * 100
shl eax,2 ; óìíîæåíèå íà 4
lea eax,[eax+eax*4] ; óìíîæåíèå íà 5
lea eax,[eax+eax*4] ; óìíîæåíèå íà 5
integer_division:
; eax = eax/ebx
test ebx,ebx
jnz @f
inc ebx
@@:
xor edx,edx
div ebx
; shl edx,1
; cmp ebx,edx
; jb @f
; inc eax
;@@:
ret
;---------------------------------------------------------------------
calculation_next_value_plus: calculation_next_value_plus:
mov ebx,[zoom_auto_factor] mov ebx,[zoom_auto_factor]
mov ecx,zoom_factors.min mov ecx,zoom_factors.min