libimg: new scale type (tile), some fixes

git-svn-id: svn://kolibrios.org@3053 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Ivan Baravy 2012-11-17 13:24:10 +00:00
parent b23bcb33f0
commit 9fcea4ddbf
7 changed files with 277 additions and 209 deletions

View File

@ -110,18 +110,12 @@ proc draw_image
inc edx inc edx
mov ebx, [image_initial] mov ebx, [image_initial]
; invoke img.scale, ebx, 1, 2, 5, 5, 0, LIBIMG_SCALE_TYPE_STRETCH, LIBIMG_SCALE_ALG_BILINEAR, edx, ecx ; invoke img.scale, ebx, 0, 0, [ebx + Image.Width], [ebx + Image.Height], 0, LIBIMG_SCALE_INTEGER, LIBIMG_INTER_NONE, 5, 5
; invoke img.scale, ebx, 1, 2, 5, 5, 0, LIBIMG_SCALE_TYPE_STRETCH, LIBIMG_SCALE_ALG_INTEGER, 3, 3 ; invoke img.scale, ebx, 1, 2, 5, 5, 0, LIBIMG_SCALE_TILE, LIBIMG_INTER_NONE, edx, ecx
invoke img.scale, ebx, 0, 0, [ebx + Image.Width], [ebx + Image.Height], 0, LIBIMG_SCALE_TYPE_STRETCH, LIBIMG_SCALE_ALG_BILINEAR, edx, ecx ; invoke img.scale, ebx, 0, 0, [ebx + Image.Width], [ebx + Image.Height], 0, LIBIMG_SCALE_TILE, LIBIMG_INTER_NONE, edx, ecx
; invoke img.scale, ebx, 1, 2, 5, 5, 0, LIBIMG_SCALE_STRETCH, LIBIMG_INTER_BILINEAR, edx, ecx
invoke img.scale, ebx, 0, 0, [ebx + Image.Width], [ebx + Image.Height], 0, LIBIMG_SCALE_STRETCH, LIBIMG_INTER_BILINEAR, edx, ecx
; proc img.scale _src, _crop_x, _crop_y, _crop_width, _crop_height, _dst, _scale_type, _scale_alg, _param1, _param2
; see libimg.inc for available scale types and algorithms
; LIBIMG_SCALE_ALG_BILINEAR: _param1, _param2 -- width and height of rectangle to fit _src image to
; LIBIMG_SCALE_ALG_INTEGER: _param1 -- scale factor (i.e. 3 means scaling 7x7 to 21x21); _param2 ignored
; LIBIMG_SCALE_TYPE_*: just try and see, they are common STRETCH, FIT_BY_WIDTH etc.
; returns pointer to a scaled image
; invoke img.scale, ebx, 0, 0, [ebx + Image.Width], [ebx + Image.Height], 0, LIBIMG_SCALE_TYPE_STRETCH, LIBIMG_SCALE_ALG_INTEGER, 3, 3
test eax, eax test eax, eax
jz exit jz exit
mov [image_scaled], eax mov [image_scaled], eax
@ -134,17 +128,18 @@ endp
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
window_title db 'img.scale example',0 window_title db 'img.scale example',0
input_file:
input_file db '/hd0/1/gray_5x7.tiff',0 ; db '/hd0/1/gray_5x7.tiff',0
;input_file db '/hd0/1/grayscale_123x123.tiff',0 db '/hd0/1/rgb_lzw_le_2x2.tiff',0
;input_file db '/hd0/1/grayscale_357x357.tiff',0 ; db '/hd0/1/grayscale_123x123.tiff',0
;input_file db '/hd0/1/grayscale_620x620.tiff',0 ; db '/hd0/1/grayscale_357x357.tiff',0
;input_file db '/hd0/1/rgb_220.jpg',0 ; db '/hd0/1/grayscale_620x620.tiff',0
;input_file db '/hd0/1/rgba_217.tiff',0 ; db '/hd0/1/rgb_220.jpg',0
;input_file db '/hd0/1/rgb_7x9.tiff',0 ; db '/hd0/1/rgba_217.tiff',0
;input_file db '/hd0/1/rgba_7x9.tiff',0 ; db '/hd0/1/rgb_7x9.tiff',0
;input_file db '/hd0/1/gray_7x9.tiff',0 ; db '/hd0/1/rgba_7x9.tiff',0
;input_file db '/hd0/1/rgb_70x90.png',0 ; db '/hd0/1/gray_7x9.tiff',0
; db '/hd0/1/rgb_70x90.png',0
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
align 4 align 4

View File

@ -1914,19 +1914,19 @@ endp
align 4 align 4
img.formats_table: img.formats_table:
.bmp dd LIBIMG_FORMAT_ID_BMP, img.is.bmp, img.decode.bmp, img.encode.bmp, 1 + (1 SHL Image.bpp24) + (1 SHL Image.bpp32) .bmp dd LIBIMG_FORMAT_BMP, img.is.bmp, img.decode.bmp, img.encode.bmp, 1 + (1 SHL Image.bpp24) + (1 SHL Image.bpp32)
.ico dd LIBIMG_FORMAT_ID_ICO, img.is.ico, img.decode.ico_cur, img.encode.ico, 0 .ico dd LIBIMG_FORMAT_ICO, img.is.ico, img.decode.ico_cur, img.encode.ico, 0
.cur dd LIBIMG_FORMAT_ID_CUR, img.is.cur, img.decode.ico_cur, img.encode.cur, 0 .cur dd LIBIMG_FORMAT_CUR, img.is.cur, img.decode.ico_cur, img.encode.cur, 0
.gif dd LIBIMG_FORMAT_ID_GIF, img.is.gif, img.decode.gif, img.encode.gif, 0 .gif dd LIBIMG_FORMAT_GIF, img.is.gif, img.decode.gif, img.encode.gif, 0
.png dd LIBIMG_FORMAT_ID_PNG, img.is.png, img.decode.png, img.encode.png, 0 .png dd LIBIMG_FORMAT_PNG, img.is.png, img.decode.png, img.encode.png, 0
.jpg dd LIBIMG_FORMAT_ID_JPEG, img.is.jpg, img.decode.jpg, img.encode.jpg, 0 .jpg dd LIBIMG_FORMAT_JPEG, img.is.jpg, img.decode.jpg, img.encode.jpg, 0
.tga dd LIBIMG_FORMAT_ID_TGA, img.is.tga, img.decode.tga, img.encode.tga, 0 .tga dd LIBIMG_FORMAT_TGA, img.is.tga, img.decode.tga, img.encode.tga, 0
.pcx dd LIBIMG_FORMAT_ID_PCX, img.is.pcx, img.decode.pcx, img.encode.pcx, 0 .pcx dd LIBIMG_FORMAT_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_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_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.bpp8g) + (1 SHL Image.bpp24) .pnm dd LIBIMG_FORMAT_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_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_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
;;================================================================================================;; ;;================================================================================================;;

View File

@ -18,34 +18,35 @@
;;================================================================================================;; ;;================================================================================================;;
; list of format id's ; list of format id's
LIBIMG_FORMAT_ID_BMP = 1 LIBIMG_FORMAT_BMP = 1
LIBIMG_FORMAT_ID_ICO = 2 LIBIMG_FORMAT_ICO = 2
LIBIMG_FORMAT_ID_CUR = 3 LIBIMG_FORMAT_CUR = 3
LIBIMG_FORMAT_ID_GIF = 4 LIBIMG_FORMAT_GIF = 4
LIBIMG_FORMAT_ID_PNG = 5 LIBIMG_FORMAT_PNG = 5
LIBIMG_FORMAT_ID_JPEG = 6 LIBIMG_FORMAT_JPEG = 6
LIBIMG_FORMAT_ID_TGA = 7 LIBIMG_FORMAT_TGA = 7
LIBIMG_FORMAT_ID_PCX = 8 LIBIMG_FORMAT_PCX = 8
LIBIMG_FORMAT_ID_XCF = 9 LIBIMG_FORMAT_XCF = 9
LIBIMG_FORMAT_ID_TIFF = 10 LIBIMG_FORMAT_TIFF = 10
LIBIMG_FORMAT_ID_PNM = 11 LIBIMG_FORMAT_PNM = 11
LIBIMG_FORMAT_ID_WBMP = 12 LIBIMG_FORMAT_WBMP = 12
LIBIMG_FORMAT_ID_Z80 = 13 LIBIMG_FORMAT_Z80 = 13
; scale type ; scale type ; corresponding img.scale params
LIBIMG_SCALE_TYPE_STRETCH = 0 LIBIMG_SCALE_INTEGER = 1 ; scale factor ; reserved 0
LIBIMG_SCALE_TYPE_FIT_RECT = 1 LIBIMG_SCALE_TILE = 2 ; new width ; new height
LIBIMG_SCALE_TYPE_FIT_WIDTH = 2 LIBIMG_SCALE_STRETCH = 3 ; new width ; new height
LIBIMG_SCALE_TYPE_FIT_HEIGHT = 3 LIBIMG_SCALE_FIT_RECT = 4 ; new width ; new height
LIBIMG_SCALE_TYPE_FIT_MAX = 4 LIBIMG_SCALE_FIT_WIDTH = 5 ; new width ; new height
;LIBIMG_SCALE_TYPE_TILE = 5 LIBIMG_SCALE_FIT_HEIGHT = 6 ; new width ; new height
LIBIMG_SCALE_FIT_MAX = 7 ; new width ; new height
; scale algorithm ; interpolation algorithm
;LIBIMG_SCALE_ALG_DEFAULT = 0 LIBIMG_INTER_NONE = 0 ; use it with LIBIMG_SCALE_INTEGER, LIBIMG_SCALE_TILE, etc
LIBIMG_SCALE_ALG_INTEGER = 1 LIBIMG_INTER_BILINEAR = 1
LIBIMG_SCALE_ALG_BILINEAR = 2 ;LIBIMG_INTER_BICUBIC = 2
;LIBIMG_SCALE_ALG_BICUBIC = 3 ;LIBIMG_INTER_LANCZOS = 3
;LIBIMG_SCALE_ALG_LANCZOS = 4 LIBIMG_INTER_DEFAULT = LIBIMG_INTER_BILINEAR
; error codes ; error codes
LIBIMG_ERROR_OUT_OF_MEMORY = 1 LIBIMG_ERROR_OUT_OF_MEMORY = 1
@ -54,9 +55,10 @@ LIBIMG_ERROR_CONDITIONS = 3
LIBIMG_ERROR_BIT_DEPTH = 4 LIBIMG_ERROR_BIT_DEPTH = 4
LIBIMG_ERROR_ENCODER = 5 LIBIMG_ERROR_ENCODER = 5
LIBIMG_ERROR_SRC_TYPE = 6 LIBIMG_ERROR_SRC_TYPE = 6
LIBIMG_ERROR_SCALE_TYPE = 7 LIBIMG_ERROR_SCALE = 7
LIBIMG_ERROR_SCALE_ALG = 8 LIBIMG_ERROR_INTER = 8
LIBIMG_ERROR_NOT_INPLEMENTED = 9 LIBIMG_ERROR_NOT_INPLEMENTED = 9
LIBIMG_ERROR_INVALID_INPUT = 10
; encode flags (byte 0x02 of _common option) ; encode flags (byte 0x02 of _common option)
LIBIMG_ENCODE_STRICT_SPECIFIC = 0x01 LIBIMG_ENCODE_STRICT_SPECIFIC = 0x01

View File

@ -18,7 +18,7 @@
;;================================================================================================;; ;;================================================================================================;;
;;================================================================================================;; ;;================================================================================================;;
proc img.scale _src, _crop_x, _crop_y, _crop_width, _crop_height, _dst, _scale_type, _scale_alg, _param1, _param2 ;; proc img.scale _src, _crop_x, _crop_y, _crop_width, _crop_height, _dst, _scale, _inter, _param1, _param2 ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;? scale _image ;; ;? scale _image ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
@ -28,10 +28,10 @@ proc img.scale _src, _crop_x, _crop_y, _crop_width, _crop_height, _dst, _scale_t
;> [_crop_width] = width of cropping rect ;; ;> [_crop_width] = width of cropping rect ;;
;> [_crop_height] = height of cropping rect ;; ;> [_crop_height] = height of cropping rect ;;
;> [_dst] = pointer to resulting image / 0 ;; ;> [_dst] = pointer to resulting image / 0 ;;
;> [_scale_type] = how to change width and height. see libimg.inc ;; ;> [_scale] = how to change width and height. see libimg.inc ;;
;> [_scale_alg] = algorithm to use. see libimg.inc ;; ;> [_inter] = interpolation algorithm ;;
;> [_param1] = the first argument passed to _scale_alg algorithm ;; ;> [_param1] = see libimg.inc ;;
;> [_param2] = the second argument passed to _scale_alg algorithm ;; ;> [_param2] = see libimg.inc ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;< eax = 0 / pointer to scaled image ;; ;< eax = 0 / pointer to scaled image ;;
;< ecx = error code / undefined ;; ;< ecx = error code / undefined ;;
@ -45,11 +45,11 @@ locals
src_width_bytes rd 1 src_width_bytes rd 1
src_height_pixels rd 1 src_height_pixels rd 1
scl_width_pixels rd 1 dst_width_pixels rd 1
scl_width_pixels_inv rd 1 dst_width_pixels_inv rd 1
scl_height_pixels rd 1 dst_height_pixels rd 1
scl_height_pixels_inv rd 1 dst_height_pixels_inv rd 1
scl_width_bytes rd 1 dst_width_bytes rd 1
bytes_per_pixel rd 1 bytes_per_pixel rd 1
crop_width_pixels_m1 rd 1 crop_width_pixels_m1 rd 1
@ -89,7 +89,7 @@ endl
jne @f jne @f
mov [bytes_per_pixel], 3 mov [bytes_per_pixel], 3
lea ecx, [ecx*3] lea ecx, [ecx*3]
lea edx, [ecx*3] lea edx, [edx*3]
jmp .lab1 jmp .lab1
@@: @@:
cmp eax, Image.bpp8g cmp eax, Image.bpp8g
@ -104,27 +104,121 @@ endl
add [src_data], edx add [src_data], edx
mov eax, [_scale_alg] mov eax, [_scale]
cmp eax, LIBIMG_SCALE_ALG_INTEGER cmp eax, LIBIMG_SCALE_INTEGER
je .integer je .scale_type.integer
cmp eax, LIBIMG_SCALE_ALG_BILINEAR cmp eax, LIBIMG_SCALE_TILE
je .bilinear je .scale_type.tile
mov ecx, LIBIMG_ERROR_SCALE_ALG cmp eax, LIBIMG_SCALE_FIT_RECT
je .scale_type.fit_rect
cmp eax, LIBIMG_SCALE_FIT_WIDTH
je .scale_type.fit_width
cmp eax, LIBIMG_SCALE_FIT_HEIGHT
je .scale_type.fit_height
cmp eax, LIBIMG_SCALE_FIT_MAX
je .scale_type.fit_max
cmp eax, LIBIMG_SCALE_STRETCH
je .scale_type.stretch
mov ecx, LIBIMG_ERROR_SCALE
jmp .error jmp .error
.scale_type.integer:
jmp .integer
.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
.scale_type.stretch:
mov eax, [_param1]
mov [dst_width_pixels], eax
imul eax, [bytes_per_pixel]
mov [dst_width_bytes], eax
mov ecx, [_param2]
mov [dst_height_pixels], ecx
jmp .define_inter
.define_inter:
mov eax, [_inter]
cmp eax, LIBIMG_INTER_BILINEAR
je .bilinear
mov ecx, LIBIMG_ERROR_INTER
jmp .error
.integer: .integer:
mov eax, [_param1] mov eax, [_param1]
mov ecx, [_crop_width] mov ecx, [_crop_width]
imul ecx, eax imul ecx, eax
mov [scl_width_pixels], ecx mov [dst_width_pixels], ecx
mov edx, [_crop_height] mov edx, [_crop_height]
imul edx, eax imul edx, eax
mov [scl_height_pixels], edx mov [dst_height_pixels], edx
mov eax, [_dst] mov eax, [_dst]
test eax, eax test eax, eax
jnz @f jnz @f
stdcall img.create, [scl_width_pixels], [scl_height_pixels], [src_type] stdcall img.create, [dst_width_pixels], [dst_height_pixels], [src_type]
test eax, eax test eax, eax
jz .error jz .error
mov [_dst], eax mov [_dst], eax
@ -144,8 +238,8 @@ endl
jmp .error jmp .error
.integer.bpp8g: .integer.bpp8g:
push [scl_width_pixels] push [dst_width_pixels]
pop [scl_width_bytes] pop [dst_width_bytes]
mov ecx, [_param1] mov ecx, [_param1]
; cmp ecx, 1 ; cmp ecx, 1
; je .error ; je .error
@ -163,10 +257,10 @@ endl
jnz @b jnz @b
push esi push esi
mov esi, edi mov esi, edi
sub esi, [scl_width_bytes] sub esi, [dst_width_bytes]
mov ecx, edx mov ecx, edx
dec ecx dec ecx
imul ecx, [scl_width_bytes] imul ecx, [dst_width_bytes]
mov eax, ecx mov eax, ecx
shr ecx, 2 shr ecx, 2
and eax, 0x00000003 and eax, 0x00000003
@ -184,9 +278,9 @@ endl
jmp .quit jmp .quit
.integer.bpp24: .integer.bpp24:
mov eax, [scl_width_pixels] mov eax, [dst_width_pixels]
lea eax, [eax*3] lea eax, [eax*3]
mov [scl_width_bytes], eax mov [dst_width_bytes], eax
mov ecx, [_param1] mov ecx, [_param1]
; cmp ecx, 1 ; cmp ecx, 1
; je .error ; je .error
@ -211,10 +305,10 @@ endl
jnz @b jnz @b
push esi push esi
mov esi, edi mov esi, edi
sub esi, [scl_width_bytes] sub esi, [dst_width_bytes]
mov ecx, edx mov ecx, edx
dec ecx dec ecx
imul ecx, [scl_width_bytes] imul ecx, [dst_width_bytes]
mov eax, ecx mov eax, ecx
shr ecx, 2 shr ecx, 2
and eax, 0x00000003 and eax, 0x00000003
@ -233,9 +327,9 @@ endl
jmp .quit jmp .quit
.integer.bpp32: .integer.bpp32:
mov eax, [scl_width_pixels] mov eax, [dst_width_pixels]
shl eax, 2 shl eax, 2
mov [scl_width_bytes], eax mov [dst_width_bytes], eax
mov ecx, [_param1] mov ecx, [_param1]
; cmp ecx, 1 ; cmp ecx, 1
; je .error ; je .error
@ -253,10 +347,10 @@ endl
jnz @b jnz @b
push esi push esi
mov esi, edi mov esi, edi
sub esi, [scl_width_bytes] sub esi, [dst_width_bytes]
mov ecx, edx mov ecx, edx
dec ecx dec ecx
imul ecx, [scl_width_bytes] imul ecx, [dst_width_bytes]
shr ecx, 2 shr ecx, 2
rep movsd rep movsd
pop esi pop esi
@ -271,98 +365,73 @@ endl
jmp .quit jmp .quit
.bilinear: .tile:
mov eax, [_scale_type]
cmp eax, LIBIMG_SCALE_TYPE_FIT_RECT
je .bilinear.fit_rect
cmp eax, LIBIMG_SCALE_TYPE_FIT_WIDTH
je .bilinear.fit_width
cmp eax, LIBIMG_SCALE_TYPE_FIT_HEIGHT
je .bilinear.fit_height
cmp eax, LIBIMG_SCALE_TYPE_FIT_MAX
je .bilinear.fit_max
cmp eax, LIBIMG_SCALE_TYPE_STRETCH
je .bilinear.stretch
mov ecx, LIBIMG_ERROR_SCALE_TYPE
jmp .error
.bilinear.fit_rect:
mov eax, [_param1] mov eax, [_param1]
shl eax, 16 mov [dst_width_pixels], eax
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 .bilinear.fit_common
.bilinear.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 .bilinear.fit_common
.bilinear.fit_width:
mov eax, [_param1]
shl eax, 16
add eax, 0x00008000
xor edx, edx
div [src_width_pixels]
mov ebx, eax
jmp .bilinear.fit_common
.bilinear.fit_height:
mov eax, [_param2]
shl eax, 16
add eax, 0x00008000
xor edx, edx
div [src_height_pixels]
mov ebx, eax
jmp .bilinear.fit_common
.bilinear.fit_common:
mov eax, [src_width_pixels]
mul ebx
shr eax, 16
mov [scl_width_pixels], eax
imul eax, [bytes_per_pixel] imul eax, [bytes_per_pixel]
mov [scl_width_bytes], eax mov [dst_width_bytes], eax
mov eax, [src_height_pixels] mov eax, [_param2]
mul ebx mov [dst_height_pixels], eax
shr eax, 16
mov [scl_height_pixels], eax
jmp .bilinear.common
.bilinear.stretch:
mov eax, [_param1]
mov [scl_width_pixels], eax
imul eax, [bytes_per_pixel]
mov [scl_width_bytes], eax
mov ecx, [_param2]
mov [scl_height_pixels], ecx
jmp .bilinear.common
.bilinear.common:
mov eax, [_dst] mov eax, [_dst]
test eax, eax test eax, eax
jnz @f jnz @f
stdcall img.create, [scl_width_pixels], [scl_height_pixels], [src_type] stdcall img.create, [dst_width_pixels], [dst_height_pixels], [src_type]
test eax, eax
jz .error
mov [_dst], eax
@@:
mov edi, [eax + Image.Data]
mov [dst_data], edi
mov esi, [src_data]
mov eax, [_crop_height]
cmp eax, [dst_height_pixels]
jna @f
mov eax, [dst_height_pixels]
@@:
push eax
mov ecx, [_crop_width]
cmp ecx, [dst_width_pixels]
jna @f
mov ecx, [dst_width_pixels]
@@:
imul ecx, [bytes_per_pixel]
mov edx, ecx
@@:
mov ecx, edx
rep movsb
push esi
mov esi, edi
sub esi, edx
mov ecx, [dst_width_bytes]
sub ecx, edx
rep movsb
pop esi
mov ecx, [src_width_bytes]
sub ecx, edx
add esi, ecx
dec eax
jnz @b
pop eax
mov esi, [dst_data]
mov ecx, [dst_height_pixels]
sub ecx, eax
imul ecx, [dst_width_bytes]
rep movsb
mov eax, [_dst]
jmp .quit
.bilinear:
mov eax, [_dst]
test eax, eax
jnz @f
stdcall img.create, [dst_width_pixels], [dst_height_pixels], [src_type]
test eax, eax test eax, eax
jz .error jz .error
mov [_dst], eax mov [_dst], eax
@ -379,12 +448,12 @@ endl
mov eax, 0xffffffff mov eax, 0xffffffff
xor edx, edx xor edx, edx
div [scl_width_pixels] div [dst_width_pixels]
mov [scl_width_pixels_inv], eax mov [dst_width_pixels_inv], eax
mov eax, 0xffffffff mov eax, 0xffffffff
xor edx, edx xor edx, edx
div [scl_height_pixels] div [dst_height_pixels]
mov [scl_height_pixels_inv], eax mov [dst_height_pixels_inv], eax
mov eax, [src_type] mov eax, [src_type]
cmp eax, Image.bpp8g cmp eax, Image.bpp8g
@ -405,7 +474,7 @@ endl
mov [dst_x], 0 mov [dst_x], 0
imul eax, [crop_height_pixels_m1] imul eax, [crop_height_pixels_m1]
xor edx, edx xor edx, edx
div [scl_height_pixels] div [dst_height_pixels]
mov [rem_y], edx mov [rem_y], edx
imul eax, [src_width_bytes] imul eax, [src_width_bytes]
add esi, eax add esi, eax
@ -417,7 +486,7 @@ endl
imul eax, [crop_width_pixels_m1] imul eax, [crop_width_pixels_m1]
xor edx, edx xor edx, edx
div [scl_width_pixels] div [dst_width_pixels]
add esi, eax add esi, eax
mov ax, word[esi] mov ax, word[esi]
@ -432,12 +501,12 @@ endl
imul edx, esi imul edx, esi
imul ecx, esi imul ecx, esi
neg esi neg esi
add esi, [scl_width_pixels] add esi, [dst_width_pixels]
imul eax, esi imul eax, esi
imul ebx, esi imul ebx, esi
add eax, edx add eax, edx
add ebx, ecx add ebx, ecx
mov esi, [scl_width_pixels_inv] mov esi, [dst_width_pixels_inv]
mul esi mul esi
mov ecx, edx mov ecx, edx
mov eax, ebx mov eax, ebx
@ -447,21 +516,21 @@ endl
mov edx, [rem_y] mov edx, [rem_y]
imul eax, edx imul eax, edx
neg edx neg edx
add edx, [scl_height_pixels] add edx, [dst_height_pixels]
imul ecx, edx imul ecx, edx
add eax, ecx add eax, ecx
mul [scl_height_pixels_inv] mul [dst_height_pixels_inv]
mov byte[edi], dl mov byte[edi], dl
add edi, 1 add edi, 1
add [dst_x], 1 add [dst_x], 1
mov eax, [dst_x] mov eax, [dst_x]
cmp eax, [scl_width_pixels] cmp eax, [dst_width_pixels]
jne .bilinear.bpp8g.pixel jne .bilinear.bpp8g.pixel
add [dst_y], 1 add [dst_y], 1
mov eax, [dst_y] mov eax, [dst_y]
cmp eax, [scl_height_pixels] cmp eax, [dst_height_pixels]
jne .bilinear.bpp8g.line jne .bilinear.bpp8g.line
mov eax, [_dst] mov eax, [_dst]
@ -477,7 +546,7 @@ endl
mov [dst_x], 0 mov [dst_x], 0
imul eax, [crop_height_pixels_m1] imul eax, [crop_height_pixels_m1]
xor edx, edx xor edx, edx
div [scl_height_pixels] div [dst_height_pixels]
mov [rem_y], edx mov [rem_y], edx
imul eax, [src_width_bytes] imul eax, [src_width_bytes]
add esi, eax add esi, eax
@ -489,7 +558,7 @@ endl
imul eax, [crop_width_pixels_m1] imul eax, [crop_width_pixels_m1]
xor edx, edx xor edx, edx
div [scl_width_pixels] div [dst_width_pixels]
lea eax, [eax*3] lea eax, [eax*3]
add esi, eax add esi, eax
@ -514,12 +583,12 @@ repeat 3
imul edx, esi imul edx, esi
imul ecx, esi imul ecx, esi
neg esi neg esi
add esi, [scl_width_pixels] add esi, [dst_width_pixels]
imul eax, esi imul eax, esi
imul ebx, esi imul ebx, esi
add eax, edx add eax, edx
add ebx, ecx add ebx, ecx
mov esi, [scl_width_pixels_inv] mov esi, [dst_width_pixels_inv]
mul esi mul esi
mov ecx, edx mov ecx, edx
mov eax, ebx mov eax, ebx
@ -529,22 +598,22 @@ repeat 3
mov edx, [rem_y] mov edx, [rem_y]
imul eax, edx imul eax, edx
neg edx neg edx
add edx, [scl_height_pixels] add edx, [dst_height_pixels]
imul ecx, edx imul ecx, edx
add eax, ecx add eax, ecx
mul [scl_height_pixels_inv] mul [dst_height_pixels_inv]
mov byte[edi], dl mov byte[edi], dl
add edi, 1 add edi, 1
end repeat end repeat
add [dst_x], 1 add [dst_x], 1
mov eax, [dst_x] mov eax, [dst_x]
cmp eax, [scl_width_pixels] cmp eax, [dst_width_pixels]
jne .bilinear.bpp24.pixel jne .bilinear.bpp24.pixel
add [dst_y], 1 add [dst_y], 1
mov eax, [dst_y] mov eax, [dst_y]
cmp eax, [scl_height_pixels] cmp eax, [dst_height_pixels]
jne .bilinear.bpp24.line jne .bilinear.bpp24.line
mov eax, [_dst] mov eax, [_dst]
@ -559,7 +628,7 @@ end repeat
mov [dst_x], 0 mov [dst_x], 0
imul eax, [crop_height_pixels_m1] imul eax, [crop_height_pixels_m1]
xor edx, edx xor edx, edx
div [scl_height_pixels] div [dst_height_pixels]
mov [rem_y], edx mov [rem_y], edx
imul eax, [src_width_bytes] imul eax, [src_width_bytes]
add esi, eax add esi, eax
@ -571,7 +640,7 @@ end repeat
imul eax, [crop_width_pixels_m1] imul eax, [crop_width_pixels_m1]
xor edx, edx xor edx, edx
div [scl_width_pixels] div [dst_width_pixels]
shl eax, 2 shl eax, 2
add esi, eax add esi, eax
@ -596,12 +665,12 @@ repeat 4
imul edx, esi imul edx, esi
imul ecx, esi imul ecx, esi
neg esi neg esi
add esi, [scl_width_pixels] add esi, [dst_width_pixels]
imul eax, esi imul eax, esi
imul ebx, esi imul ebx, esi
add eax, edx add eax, edx
add ebx, ecx add ebx, ecx
mov esi, [scl_width_pixels_inv] mov esi, [dst_width_pixels_inv]
mul esi mul esi
mov ecx, edx mov ecx, edx
mov eax, ebx mov eax, ebx
@ -611,22 +680,22 @@ repeat 4
mov edx, [rem_y] mov edx, [rem_y]
imul eax, edx imul eax, edx
neg edx neg edx
add edx, [scl_height_pixels] add edx, [dst_height_pixels]
imul ecx, edx imul ecx, edx
add eax, ecx add eax, ecx
mul [scl_height_pixels_inv] mul [dst_height_pixels_inv]
mov byte[edi], dl mov byte[edi], dl
add edi, 1 add edi, 1
end repeat end repeat
add [dst_x], 1 add [dst_x], 1
mov eax, [dst_x] mov eax, [dst_x]
cmp eax, [scl_width_pixels] cmp eax, [dst_width_pixels]
jne .bilinear.bpp32.pixel jne .bilinear.bpp32.pixel
add [dst_y], 1 add [dst_y], 1
mov eax, [dst_y] mov eax, [dst_y]
cmp eax, [scl_height_pixels] cmp eax, [dst_height_pixels]
jne .bilinear.bpp32.line jne .bilinear.bpp32.line
mov eax, [_dst] mov eax, [_dst]

View File

@ -395,6 +395,8 @@ endl
.post.predictor: .post.predictor:
cmp [ebx + tiff_extra.predictor], 2 ; Horizontal differencing cmp [ebx + tiff_extra.predictor], 2 ; Horizontal differencing
jne .post.end jne .post.end
cmp [ebx + tiff_extra.image_width], 1
je .post.end
push ebx push ebx
mov edi, [ebx + tiff_extra.samples_per_pixel] mov edi, [ebx + tiff_extra.samples_per_pixel]
mov edx, edi mov edx, edi