img.scale and img.convert fix for multiframe images
new function: img.get_scaled_size git-svn-id: svn://kolibrios.org@6807 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
c299820b03
commit
741b6ad89c
@ -17,15 +17,70 @@
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.convert _src, _dst, _dst_type, _flags, _param ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? scale _image ;;
|
||||
;? convert _image ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> [_src] = pointer to source image ;;
|
||||
;> [_dst] = pointer to destination image, or 0 to create a new one ;;
|
||||
;> [_dst_type] = Image.Type of resulting image ;;
|
||||
;> [_flags] = see libimg.inc ;;
|
||||
;> [_dst_type] = the Image.Type of converted image ;;
|
||||
;> [_dst] = pointer to destination image, if any ;;
|
||||
;> [_param] = depends on _flags fields, see libimg.inc ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 / pointer to converted 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.convert.layer, ebx, [_dst], [_dst_type], [_flags], [_param]
|
||||
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.convert.layer _src, _dst, _dst_type, _flags, _param ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? convert _image layer ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> [_src] = pointer to source image ;;
|
||||
;> [_dst] = pointer to destination image, or 0 to create a new one ;;
|
||||
;> [_dst_type] = Image.Type of resulting image ;;
|
||||
;> [_flags] = see libimg.inc ;;
|
||||
;> [_param] = depends on _flags fields, see libimg.inc ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 / pointer to converted image ;;
|
||||
;< ecx = error code / undefined ;;
|
||||
@ -34,6 +89,8 @@ locals
|
||||
width rd 1
|
||||
height rd 1
|
||||
endl
|
||||
push ebx esi edi
|
||||
|
||||
mov ebx, [_src]
|
||||
mov eax, 1
|
||||
mov ecx, [_dst_type]
|
||||
@ -151,6 +208,13 @@ endl
|
||||
mov eax, [_dst]
|
||||
jmp .quit
|
||||
|
||||
.bpp8g_to_bpp8g:
|
||||
mov ecx, [ebx + Image.Width]
|
||||
imul ecx, [ebx + Image.Height]
|
||||
rep movsb
|
||||
mov eax, [_dst]
|
||||
jmp .quit
|
||||
|
||||
.bpp8g_to_bpp24:
|
||||
mov ecx, [ebx + Image.Width]
|
||||
imul ecx, [ebx + Image.Height]
|
||||
@ -199,6 +263,19 @@ endl
|
||||
jnz @b
|
||||
mov eax, [_dst]
|
||||
jmp .quit
|
||||
.bpp24_to_bpp32:
|
||||
mov ecx, [ebx + Image.Width]
|
||||
imul ecx, [ebx + Image.Height]
|
||||
@@:
|
||||
lodsw
|
||||
ror eax, 16
|
||||
lodsb
|
||||
rol eax, 16
|
||||
stosd
|
||||
dec ecx
|
||||
jnz @b
|
||||
mov eax, [_dst]
|
||||
jmp .quit
|
||||
|
||||
|
||||
.bpp32:
|
||||
@ -561,25 +638,28 @@ end repeat
|
||||
.error:
|
||||
xor eax, eax
|
||||
.quit:
|
||||
pop edi esi ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
img.convert.bpp8i.table:
|
||||
dd Image.bpp24, img.convert.bpp8i_to_bpp24
|
||||
dd Image.bpp24, img.convert.layer.bpp8i_to_bpp24
|
||||
img.convert.bpp8g.table:
|
||||
dd Image.bpp24, img.convert.bpp8g_to_bpp24
|
||||
dd Image.bpp1, img.convert.bpp8g_to_bpp1
|
||||
dd Image.bpp24, img.convert.layer.bpp8g_to_bpp24
|
||||
dd Image.bpp8g, img.convert.layer.bpp8g_to_bpp8g
|
||||
dd Image.bpp1, img.convert.layer.bpp8g_to_bpp1
|
||||
img.convert.bpp24.table:
|
||||
dd Image.bpp24, img.convert.bpp24_to_bpp24
|
||||
dd Image.bpp8g, img.convert.bpp24_to_bpp8g
|
||||
dd Image.bpp24, img.convert.layer.bpp24_to_bpp24
|
||||
dd Image.bpp8g, img.convert.layer.bpp24_to_bpp8g
|
||||
dd Image.bpp32, img.convert.layer.bpp24_to_bpp32
|
||||
img.convert.bpp32.table:
|
||||
dd Image.bpp24, img.convert.bpp32_to_bpp24
|
||||
dd Image.bpp24, img.convert.layer.bpp32_to_bpp24
|
||||
img.convert.bpp15.table:
|
||||
dd Image.bpp24, img.convert.bpp15_to_bpp24
|
||||
dd Image.bpp24, img.convert.layer.bpp15_to_bpp24
|
||||
img.convert.bpp16.table:
|
||||
dd Image.bpp24, img.convert.bpp16_to_bpp24
|
||||
dd Image.bpp24, img.convert.layer.bpp16_to_bpp24
|
||||
img.convert.bpp1.table:
|
||||
dd Image.bpp24, img.convert.bpp1_to_bpp24
|
||||
dd Image.bpp24, img.convert.layer.bpp1_to_bpp24
|
||||
img.convert.bpp8a.table:
|
||||
dd Image.bpp24, img.convert.bpp8a_to_bpp24
|
||||
dd Image.bpp24, img.convert.layer.bpp8a_to_bpp24
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,124 +1,127 @@
|
||||
;;================================================================================================;;
|
||||
;;//// libimg.inc //// (c) mike.dld, 2007-2008, (c) diamond, 2009, (c) dunkaist, 2011-2013 ///////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; This file is part of Common development libraries (Libs-Dev). ;;
|
||||
;; ;;
|
||||
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
|
||||
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
|
||||
;; of the License, or (at your option) any later version. ;;
|
||||
;; ;;
|
||||
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
|
||||
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
|
||||
;; Lesser General Public License for more details. ;;
|
||||
;; ;;
|
||||
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
|
||||
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
; list of format id's
|
||||
LIBIMG_FORMAT_BMP = 1
|
||||
LIBIMG_FORMAT_ICO = 2
|
||||
LIBIMG_FORMAT_CUR = 3
|
||||
LIBIMG_FORMAT_GIF = 4
|
||||
LIBIMG_FORMAT_PNG = 5
|
||||
LIBIMG_FORMAT_JPEG = 6
|
||||
LIBIMG_FORMAT_TGA = 7
|
||||
LIBIMG_FORMAT_PCX = 8
|
||||
LIBIMG_FORMAT_XCF = 9
|
||||
LIBIMG_FORMAT_TIFF = 10
|
||||
LIBIMG_FORMAT_PNM = 11
|
||||
LIBIMG_FORMAT_WBMP = 12
|
||||
LIBIMG_FORMAT_XBM = 13
|
||||
LIBIMG_FORMAT_Z80 = 14
|
||||
|
||||
; scale type ; corresponding img.scale params
|
||||
LIBIMG_SCALE_INTEGER = 1 ; scale factor ; reserved 0
|
||||
LIBIMG_SCALE_TILE = 2 ; new width ; new height
|
||||
LIBIMG_SCALE_STRETCH = 3 ; new width ; new height
|
||||
LIBIMG_SCALE_FIT_RECT = 4 ; new width ; new height
|
||||
LIBIMG_SCALE_FIT_WIDTH = 5 ; new width ; new height
|
||||
LIBIMG_SCALE_FIT_HEIGHT = 6 ; new width ; new height
|
||||
LIBIMG_SCALE_FIT_MAX = 7 ; new width ; new height
|
||||
|
||||
; interpolation algorithm
|
||||
LIBIMG_INTER_NONE = 0 ; use it with LIBIMG_SCALE_INTEGER, LIBIMG_SCALE_TILE, etc
|
||||
LIBIMG_INTER_BILINEAR = 1
|
||||
;LIBIMG_INTER_BICUBIC = 2
|
||||
;LIBIMG_INTER_LANCZOS = 3
|
||||
LIBIMG_INTER_DEFAULT = LIBIMG_INTER_BILINEAR
|
||||
|
||||
; error codes
|
||||
LIBIMG_ERROR_OUT_OF_MEMORY = 1
|
||||
LIBIMG_ERROR_FORMAT = 2
|
||||
LIBIMG_ERROR_CONDITIONS = 3
|
||||
LIBIMG_ERROR_BIT_DEPTH = 4
|
||||
LIBIMG_ERROR_ENCODER = 5
|
||||
LIBIMG_ERROR_SRC_TYPE = 6
|
||||
LIBIMG_ERROR_SCALE = 7
|
||||
LIBIMG_ERROR_INTER = 8
|
||||
LIBIMG_ERROR_NOT_INPLEMENTED = 9
|
||||
LIBIMG_ERROR_INVALID_INPUT = 10
|
||||
|
||||
; encode flags (byte 0x02 of _common option)
|
||||
LIBIMG_ENCODE_STRICT_SPECIFIC = 0x01
|
||||
LIBIMG_ENCODE_STRICT_BIT_DEPTH = 0x02
|
||||
LIBIMG_ENCODE_DELETE_ALPHA = 0x08
|
||||
LIBIMG_ENCODE_FLUSH_ALPHA = 0x10
|
||||
|
||||
; convert flags
|
||||
; TBD
|
||||
|
||||
struct FormatsTableEntry
|
||||
Format_id dd ?
|
||||
Is dd ?
|
||||
Decode dd ?
|
||||
Encode dd ?
|
||||
Capabilities dd ?
|
||||
ends
|
||||
|
||||
struct Image
|
||||
Checksum dd ? ; ((Width ROL 16) OR Height) XOR Data[0] ; ignored so far
|
||||
Width dd ?
|
||||
Height dd ?
|
||||
Next dd ?
|
||||
Previous dd ?
|
||||
Type dd ? ; one of Image.bppN
|
||||
Data dd ?
|
||||
Palette dd ? ; used iff Type eq Image.bpp1, Image.bpp2, Image.bpp4 or Image.bpp8i
|
||||
Extended dd ?
|
||||
Flags dd ? ; bitfield
|
||||
Delay dd ? ; used iff Image.IsAnimated is set in Flags
|
||||
ends
|
||||
|
||||
; values for Image.Type
|
||||
; must be consecutive to allow fast switch on Image.Type in support functions
|
||||
Image.bpp8i = 1 ; indexed
|
||||
Image.bpp24 = 2
|
||||
Image.bpp32 = 3
|
||||
Image.bpp15 = 4
|
||||
Image.bpp16 = 5
|
||||
Image.bpp1 = 6
|
||||
Image.bpp8g = 7 ; grayscale
|
||||
Image.bpp2i = 8
|
||||
Image.bpp4i = 9
|
||||
Image.bpp8a = 10 ; grayscale with alpha channel; application layer only!!! kernel doesn't handle this image type, libimg can only create and destroy such images
|
||||
|
||||
; bits in Image.Flags
|
||||
Image.IsAnimated = 1
|
||||
|
||||
struct ImageDecodeOptions
|
||||
UsedSize dd ? ; if >=8, the field BackgroundColor is valid, and so on
|
||||
BackgroundColor dd ? ; used for transparent images as background
|
||||
ends
|
||||
|
||||
FLIP_VERTICAL = 0x01
|
||||
FLIP_HORIZONTAL = 0x02
|
||||
FLIP_BOTH = FLIP_VERTICAL or FLIP_HORIZONTAL
|
||||
|
||||
ROTATE_90_CW = 0x01
|
||||
ROTATE_180 = 0x02
|
||||
ROTATE_270_CW = 0x03
|
||||
ROTATE_90_CCW = ROTATE_270_CW
|
||||
ROTATE_270_CCW = ROTATE_90_CW
|
||||
;;================================================================================================;;
|
||||
;;//// libimg.inc //// (c) mike.dld, 2007-2008, (c) diamond, 2009, (c) dunkaist, 2011-2013 ///////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; This file is part of Common development libraries (Libs-Dev). ;;
|
||||
;; ;;
|
||||
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
|
||||
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
|
||||
;; of the License, or (at your option) any later version. ;;
|
||||
;; ;;
|
||||
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
|
||||
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
|
||||
;; Lesser General Public License for more details. ;;
|
||||
;; ;;
|
||||
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
|
||||
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
; list of format id's
|
||||
LIBIMG_FORMAT_BMP = 1
|
||||
LIBIMG_FORMAT_ICO = 2
|
||||
LIBIMG_FORMAT_CUR = 3
|
||||
LIBIMG_FORMAT_GIF = 4
|
||||
LIBIMG_FORMAT_PNG = 5
|
||||
LIBIMG_FORMAT_JPEG = 6
|
||||
LIBIMG_FORMAT_TGA = 7
|
||||
LIBIMG_FORMAT_PCX = 8
|
||||
LIBIMG_FORMAT_XCF = 9
|
||||
LIBIMG_FORMAT_TIFF = 10
|
||||
LIBIMG_FORMAT_PNM = 11
|
||||
LIBIMG_FORMAT_WBMP = 12
|
||||
LIBIMG_FORMAT_XBM = 13
|
||||
LIBIMG_FORMAT_Z80 = 14
|
||||
|
||||
; scale type ; corresponding img.scale params
|
||||
LIBIMG_SCALE_NONE = 0 ; do not scale
|
||||
LIBIMG_SCALE_INTEGER = 1 ; scale factor ; reserved 0
|
||||
LIBIMG_SCALE_TILE = 2 ; new width ; new height
|
||||
LIBIMG_SCALE_STRETCH = 3 ; new width ; new height
|
||||
LIBIMG_SCALE_FIT_BOTH = LIBIMG_SCALE_STRETCH
|
||||
LIBIMG_SCALE_FIT_MIN = 4 ; new width ; new height
|
||||
LIBIMG_SCALE_FIT_RECT = LIBIMG_SCALE_FIT_MIN
|
||||
LIBIMG_SCALE_FIT_WIDTH = 5 ; new width ; new height
|
||||
LIBIMG_SCALE_FIT_HEIGHT = 6 ; new width ; new height
|
||||
LIBIMG_SCALE_FIT_MAX = 7 ; new width ; new height
|
||||
|
||||
; interpolation algorithm
|
||||
LIBIMG_INTER_NONE = 0 ; use it with LIBIMG_SCALE_INTEGER, LIBIMG_SCALE_TILE, etc
|
||||
LIBIMG_INTER_BILINEAR = 1
|
||||
;LIBIMG_INTER_BICUBIC = 2
|
||||
;LIBIMG_INTER_LANCZOS = 3
|
||||
LIBIMG_INTER_DEFAULT = LIBIMG_INTER_BILINEAR
|
||||
|
||||
; error codes
|
||||
LIBIMG_ERROR_OUT_OF_MEMORY = 1
|
||||
LIBIMG_ERROR_FORMAT = 2
|
||||
LIBIMG_ERROR_CONDITIONS = 3
|
||||
LIBIMG_ERROR_BIT_DEPTH = 4
|
||||
LIBIMG_ERROR_ENCODER = 5
|
||||
LIBIMG_ERROR_SRC_TYPE = 6
|
||||
LIBIMG_ERROR_SCALE = 7
|
||||
LIBIMG_ERROR_INTER = 8
|
||||
LIBIMG_ERROR_NOT_INPLEMENTED = 9
|
||||
LIBIMG_ERROR_INVALID_INPUT = 10
|
||||
|
||||
; encode flags (byte 0x02 of _common option)
|
||||
;LIBIMG_ENCODE_STRICT_SPECIFIC = 0x01
|
||||
LIBIMG_ENCODE_STRICT_BIT_DEPTH = 0x02
|
||||
;LIBIMG_ENCODE_DELETE_ALPHA = 0x08
|
||||
;LIBIMG_ENCODE_FLUSH_ALPHA = 0x10
|
||||
|
||||
; convert flags
|
||||
; none so far
|
||||
|
||||
struct FormatsTableEntry
|
||||
Format_id dd ?
|
||||
Is dd ?
|
||||
Decode dd ?
|
||||
Encode dd ?
|
||||
Capabilities dd ?
|
||||
ends
|
||||
|
||||
struct Image
|
||||
Checksum dd ? ; ((Width ROL 16) OR Height) XOR Data[0] ; ignored so far
|
||||
Width dd ?
|
||||
Height dd ?
|
||||
Next dd ?
|
||||
Previous dd ?
|
||||
Type dd ? ; one of Image.bppN
|
||||
Data dd ?
|
||||
Palette dd ? ; used iff Type eq Image.bpp1, Image.bpp2, Image.bpp4 or Image.bpp8i
|
||||
Extended dd ?
|
||||
Flags dd ? ; bitfield
|
||||
Delay dd ? ; used iff Image.IsAnimated is set in Flags
|
||||
ends
|
||||
|
||||
; values for Image.Type
|
||||
; must be consecutive to allow fast switch on Image.Type in support functions
|
||||
Image.bpp8i = 1 ; indexed
|
||||
Image.bpp24 = 2
|
||||
Image.bpp32 = 3
|
||||
Image.bpp15 = 4
|
||||
Image.bpp16 = 5
|
||||
Image.bpp1 = 6
|
||||
Image.bpp8g = 7 ; grayscale
|
||||
Image.bpp2i = 8
|
||||
Image.bpp4i = 9
|
||||
Image.bpp8a = 10 ; grayscale with alpha channel; application layer only!!! kernel doesn't handle this image type, libimg can only create and destroy such images
|
||||
|
||||
; bits in Image.Flags
|
||||
Image.IsAnimated = 1
|
||||
|
||||
struct ImageDecodeOptions
|
||||
UsedSize dd ? ; if >=8, the field BackgroundColor is valid, and so on
|
||||
BackgroundColor dd ? ; used for transparent images as background
|
||||
ends
|
||||
|
||||
FLIP_VERTICAL = 0x01
|
||||
FLIP_HORIZONTAL = 0x02
|
||||
FLIP_BOTH = FLIP_VERTICAL or FLIP_HORIZONTAL
|
||||
|
||||
ROTATE_90_CW = 0x01
|
||||
ROTATE_180 = 0x02
|
||||
ROTATE_270_CW = 0x03
|
||||
ROTATE_90_CCW = ROTATE_270_CW
|
||||
ROTATE_270_CCW = ROTATE_90_CW
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user