17,7 → 17,90 |
;; ;; |
;;================================================================================================;; |
|
|
;;================================================================================================;; |
proc img.get_scaled_size _width, _height, _scale_type, _param1, _param2 ;; |
;;------------------------------------------------------------------------------------------------;; |
;? calculate resulting width and height if image of _width and _height is scaled via _scale_type ;; |
;;------------------------------------------------------------------------------------------------;; |
;> [_width] = width of input image ;; |
;> [_height] = height of input image ;; |
;> [_scale_type] = see libimg.inc (LIBIMG_SCALE_*) ;; |
;> [_param1] = depends on _scale_type, see libimg.inc ;; |
;> [_param2] = depends on _scale_type, see libimg.inc ;; |
;;------------------------------------------------------------------------------------------------;; |
;< eax = width ;; |
;< ecx = height ;; |
;;================================================================================================;; |
push ebx esi edi |
mov eax, [_scale_type] |
cmp eax, LIBIMG_SCALE_FIT_MIN |
jz .fit_min |
|
.fit_min: |
xor edx, edx |
mov eax, [_width] |
shl eax, 1 |
mov ecx, [_param1] |
add eax, ecx |
shl eax, 15 |
div ecx |
mov ebx, eax |
|
xor edx, edx |
mov eax, [_height] |
shl eax, 1 |
mov ecx, [_param2] |
add eax, ecx |
shl eax, 15 |
div ecx |
|
cmp eax, ebx |
ja .fit_height |
jmp .fit_width |
|
jmp .quit |
.fit_max: |
jmp .quit |
.fit_width: |
xor edx, edx |
mov eax, [_width] |
shl eax, 16 |
div [_param1] |
mov ecx, eax |
xor edx, edx |
mov eax, [_height] |
shl eax, 16 |
mov ebx, ecx |
shr ebx, 1 |
add eax, ebx |
div ecx |
mov ecx, eax |
mov eax, [_param1] |
jmp .quit |
.fit_height: |
xor edx, edx |
mov eax, [_height] |
shl eax, 16 |
div [_param2] |
mov ecx, eax |
xor edx, edx |
mov eax, [_width] |
shl eax, 16 |
mov ebx, ecx |
shr ebx, 1 |
add eax, ebx |
div ecx |
mov ecx, [_param2] |
jmp .quit |
|
.quit: |
pop edi esi ebx |
ret |
endp |
|
|
;;================================================================================================;; |
proc img.scale _src, _crop_x, _crop_y, _crop_width, _crop_height, _dst, _scale, _inter, _param1, _param2 ;; |
;;------------------------------------------------------------------------------------------------;; |
;? scale _image ;; |
27,15 → 110,72 |
;> [_crop_y] = top coord of cropping rect ;; |
;> [_crop_width] = width of cropping rect ;; |
;> [_crop_height] = height of cropping rect ;; |
;> [_dst] = pointer to resulting image / 0 ;; |
;> [_scale] = how to change width and height. see libimg.inc ;; |
;> [_inter] = interpolation algorithm ;; |
;> [_param1] = see libimg.inc ;; |
;> [_param2] = see libimg.inc ;; |
;> [_dst] = pointer to resulting image, 0 to create new one ;; |
;> [_scale] = scaling method, see libimg.inc (LIBIMG_SCALE_*) ;; |
;> [_inter] = interpolation algorithm, see libimg.inc (LIBIMG_INTER_*) ;; |
;> [_param1] = depends on _scale, see libimg.inc ;; |
;> [_param2] = depends on _scale, see libimg.inc ;; |
;;------------------------------------------------------------------------------------------------;; |
;< eax = 0 / pointer to scaled image ;; |
;< ecx = error code / undefined ;; |
;;================================================================================================;; |
push ebx esi edi 0 0 |
mov ebx, [_src] |
@@: |
mov eax, [ebx + Image.Previous] |
test eax, eax |
jz .loop |
mov ebx, eax |
jmp @b |
.loop: |
stdcall img.scale.layer, ebx, [_crop_x], [_crop_y], [_crop_width], [_crop_height], [_dst], [_scale], [_inter], [_param1], [_param2] |
test eax, eax |
jz .error |
cmp dword[esp + 4], 0 |
jnz @f |
mov [esp + 4], eax |
@@: |
mov ecx, [esp] |
jecxz @f |
mov [ecx + Image.Next], eax |
@@: |
push [ebx + Image.Flags] |
pop [eax + Image.Flags] |
push [ebx + Image.Delay] |
pop [eax + Image.Delay] |
mov [eax + Image.Previous], ecx |
mov [esp], eax |
mov ebx, [ebx + Image.Next] |
test ebx, ebx |
jnz .loop |
.quit: |
pop eax eax edi esi ebx |
ret |
.error: |
pop eax eax edi esi ebx |
ret |
endp |
|
|
;;================================================================================================;; |
proc img.scale.layer _src, _crop_x, _crop_y, _crop_width, _crop_height, _dst, _scale, _inter, _param1, _param2 ;; |
;;------------------------------------------------------------------------------------------------;; |
;? scale _image layer ;; |
;;------------------------------------------------------------------------------------------------;; |
;> [_src] = pointer to source image ;; |
;> [_crop_x] = left coord of cropping rect ;; |
;> [_crop_y] = top coord of cropping rect ;; |
;> [_crop_width] = width of cropping rect ;; |
;> [_crop_height] = height of cropping rect ;; |
;> [_dst] = pointer to resulting image, 0 to create new one ;; |
;> [_scale] = scaling method, see libimg.inc (LIBIMG_SCALE_*) ;; |
;> [_inter] = interpolation algorithm, see libimg.inc (LIBIMG_INTER_*) ;; |
;> [_param1] = depends on _scale, see libimg.inc ;; |
;> [_param2] = depends on _scale, see libimg.inc ;; |
;;------------------------------------------------------------------------------------------------;; |
;< eax = 0 / pointer to scaled image ;; |
;< ecx = error code / undefined ;; |
;;================================================================================================;; |
locals |
src_type rd 1 |
src_data rd 1 |
63,6 → 203,7 |
rem_x rd 1 |
rem_y rd 1 |
endl |
push ebx esi edi |
mov ebx, [_src] |
push [ebx + Image.Width] |
pop [src_width_pixels] |
127,69 → 268,13 |
.scale_type.tile: |
jmp .tile |
.scale_type.fit_rect: |
mov eax, [_param1] |
shl eax, 16 |
add eax, 0x00008000 |
xor edx, edx |
div [src_width_pixels] |
mov ebx, eax |
mov eax, [_param2] |
shl eax, 16 |
add eax, 0x00008000 |
xor edx, edx |
div [src_height_pixels] |
mov ecx, eax |
cmp ebx, ecx |
jb @f |
mov ebx, ecx |
@@: |
jmp .scale_type.fit_common |
.scale_type.fit_max: |
mov eax, [_param1] |
shl eax, 16 |
add eax, 0x00008000 |
xor edx, edx |
div [src_width_pixels] |
mov ebx, eax |
mov eax, [_param2] |
shl eax, 16 |
add eax, 0x00008000 |
xor edx, edx |
div [src_height_pixels] |
mov ecx, eax |
cmp ebx, ecx |
ja @f |
mov ebx, ecx |
@@: |
jmp .scale_type.fit_common |
.scale_type.fit_width: |
mov eax, [_param1] |
shl eax, 16 |
add eax, 0x00008000 |
xor edx, edx |
div [src_width_pixels] |
mov ebx, eax |
jmp .scale_type.fit_common |
.scale_type.fit_height: |
mov eax, [_param2] |
shl eax, 16 |
add eax, 0x00008000 |
xor edx, edx |
div [src_height_pixels] |
mov ebx, eax |
jmp .scale_type.fit_common |
.scale_type.fit_common: |
mov eax, [src_width_pixels] |
mul ebx |
shr eax, 16 |
mov [dst_width_pixels], eax |
imul eax, [bytes_per_pixel] |
mov [dst_width_bytes], eax |
mov eax, [src_height_pixels] |
mul ebx |
shr eax, 16 |
mov [dst_height_pixels], eax |
jmp .define_inter |
mov eax, [_src] |
stdcall img.get_scaled_size, [eax + Image.Width], [eax + Image.Height], [_scale], [_param1], [_param2] |
mov [_param1], eax |
mov [_param2], ecx |
.scale_type.stretch: |
mov eax, [_param1] |
mov [dst_width_pixels], eax |
222,6 → 307,15 |
test eax, eax |
jz .error |
mov [_dst], eax |
mov edi, [_src] |
push [edi + Image.Flags] |
pop [eax + Image.Flags] |
push [edi + Image.Delay] |
pop [eax + Image.Delay] |
push [edi + Image.Previous] |
pop [eax + Image.Previous] |
push [edi + Image.Next] |
pop [eax + Image.Next] |
@@: |
mov edi, [eax + Image.Data] |
mov [dst_data], edi |
380,6 → 474,15 |
test eax, eax |
jz .error |
mov [_dst], eax |
mov edi, [_src] |
push [edi + Image.Flags] |
pop [eax + Image.Flags] |
push [edi + Image.Delay] |
pop [eax + Image.Delay] |
push [edi + Image.Previous] |
pop [eax + Image.Previous] |
push [edi + Image.Next] |
pop [eax + Image.Next] |
@@: |
mov edi, [eax + Image.Data] |
mov [dst_data], edi |
435,6 → 538,15 |
test eax, eax |
jz .error |
mov [_dst], eax |
mov edi, [_src] |
push [edi + Image.Flags] |
pop [eax + Image.Flags] |
push [edi + Image.Delay] |
pop [eax + Image.Delay] |
push [edi + Image.Previous] |
pop [eax + Image.Previous] |
push [edi + Image.Next] |
pop [eax + Image.Next] |
@@: |
mov edi, [eax + Image.Data] |
mov [dst_data], edi |
705,7 → 817,7 |
.error: |
xor eax, eax |
.quit: |
pop edi esi ebx |
ret |
|
endp |
|
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |