forked from KolibriOS/kolibrios
libimg: Add and export img.blend function
git-svn-id: svn://kolibrios.org@8341 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -1,2 +1,6 @@
|
|||||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||||
tup.rule("libimg.asm", "fasm -m 32768 %f %o " .. tup.getconfig("KPACK_CMD"), "libimg.obj")
|
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../../.." or tup.getconfig("HELPERDIR")
|
||||||
|
tup.include(HELPERDIR .. "/use_fasm.lua")
|
||||||
|
|
||||||
|
add_include(HELPERDIR .. "/develop/libraries/libs-dev/libio")
|
||||||
|
tup.rule("libimg.asm", FASM .. " -m 32768 %f %o " .. tup.getconfig("KPACK_CMD"), "%B.obj")
|
||||||
|
76
programs/develop/libraries/libs-dev/libimg/blend.asm
Normal file
76
programs/develop/libraries/libs-dev/libimg/blend.asm
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
match =MMX, COMPOSITE_MODE {include 'blend_mmx.asm'}
|
||||||
|
match =SSE, COMPOSITE_MODE {include 'blend_sse.asm'}
|
||||||
|
|
||||||
|
;;============================================================================;;
|
||||||
|
proc img.blend uses ebx esi edi, _bottom, _top, _xbottom, _ybottom, \ ;///////;;
|
||||||
|
_xtop, _ytop, _width, _height ;//////////////;;
|
||||||
|
;;----------------------------------------------------------------------------;;
|
||||||
|
;? Alpha blend _top image to _bottom one (both must be of type Image.bpp32) ;;
|
||||||
|
;;----------------------------------------------------------------------------;;
|
||||||
|
;> _bottom = pointer to bottom image (will be changed) ;;
|
||||||
|
;> _top = pointer to top image (unchanged) ;;
|
||||||
|
;> _xbottom = x coord inside _bottom image where to put _top image ;;
|
||||||
|
;> _ybottom = y coord inside _bottom image where to put _top image ;;
|
||||||
|
;> _xtop = x coord inside _top image to start from ;;
|
||||||
|
;> _ytop = y coord inside _top image to start from ;;
|
||||||
|
;> _width = width of _top image area to put to _bottom image ;;
|
||||||
|
;> _height = height of _top image area to put to _bottom image ;;
|
||||||
|
;;----------------------------------------------------------------------------;;
|
||||||
|
;< eax = 0 (fail) / _bottom (ok) ;;
|
||||||
|
;;============================================================================;;
|
||||||
|
mov esi, [_top]
|
||||||
|
mov edi, [_bottom]
|
||||||
|
|
||||||
|
mov eax, [esi+Image.Width]
|
||||||
|
sub eax, [_width]
|
||||||
|
shl eax, 2
|
||||||
|
push eax
|
||||||
|
|
||||||
|
mov eax, [edi+Image.Width]
|
||||||
|
sub eax, [_width]
|
||||||
|
shl eax, 2
|
||||||
|
push eax
|
||||||
|
|
||||||
|
mov eax, [_ytop]
|
||||||
|
imul eax, [esi+Image.Width]
|
||||||
|
add eax, [_xtop]
|
||||||
|
shl eax, 2
|
||||||
|
mov esi, [esi+Image.Data]
|
||||||
|
add esi, eax
|
||||||
|
|
||||||
|
mov eax, [_ybottom]
|
||||||
|
imul eax, [edi+Image.Width]
|
||||||
|
add eax, [_xbottom]
|
||||||
|
shl eax, 2
|
||||||
|
mov edi, [edi+Image.Data]
|
||||||
|
add edi, eax
|
||||||
|
stdcall xcf._.composite_rgb_00, [_width], [_height]
|
||||||
|
mov eax, [_bottom]
|
||||||
|
ret
|
||||||
|
endp
|
||||||
|
|
||||||
|
|
||||||
|
xcf._.composite_table.begin:
|
||||||
|
.p00 dd 00, xcf._.composite_rgb_00, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Normal
|
||||||
|
.p01 dd 01, xcf._.composite_rgb_01, xcf._.composite_gray_01, xcf._.composite_gray_01 ; Dissolve : random dithering to discrete alpha
|
||||||
|
; .p02 dd 02, xcf._.composite_rgb_02, 0, xcf._.composite_indexed_02 ; Behind : not selectable in the GIMP UI. not implemented
|
||||||
|
.p03 dd 03, xcf._.composite_rgb_03, xcf._.composite_rgb_03, xcf._.composite_indexed_00 ; Multiply
|
||||||
|
.p04 dd 04, xcf._.composite_rgb_04, xcf._.composite_rgb_04, xcf._.composite_indexed_00 ; Screen
|
||||||
|
.p05 dd 05, xcf._.composite_rgb_05, xcf._.composite_rgb_05, xcf._.composite_indexed_00 ; Overlay
|
||||||
|
.p06 dd 06, xcf._.composite_rgb_06, xcf._.composite_rgb_06, xcf._.composite_indexed_00 ; Difference
|
||||||
|
.p07 dd 07, xcf._.composite_rgb_07, xcf._.composite_rgb_07, xcf._.composite_indexed_00 ; Addition
|
||||||
|
.p08 dd 08, xcf._.composite_rgb_08, xcf._.composite_rgb_08, xcf._.composite_indexed_00 ; Subtract
|
||||||
|
.p09 dd 09, xcf._.composite_rgb_09, xcf._.composite_rgb_09, xcf._.composite_indexed_00 ; Darken Only
|
||||||
|
.p10 dd 10, xcf._.composite_rgb_10, xcf._.composite_rgb_10, xcf._.composite_indexed_00 ; Lighten Only
|
||||||
|
.p11 dd 11, xcf._.composite_rgb_11, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Hue (H of HSV)
|
||||||
|
.p12 dd 12, xcf._.composite_rgb_12, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Saturation (S of HSV)
|
||||||
|
.p13 dd 13, xcf._.composite_rgb_13, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Color (H and S of HSL)
|
||||||
|
.p14 dd 14, xcf._.composite_rgb_14, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Value (V of HSV)
|
||||||
|
.p15 dd 15, xcf._.composite_rgb_15, xcf._.composite_rgb_15, xcf._.composite_indexed_00 ; Divide
|
||||||
|
.p16 dd 16, xcf._.composite_rgb_16, xcf._.composite_rgb_16, xcf._.composite_indexed_00 ; Dodge
|
||||||
|
.p17 dd 17, xcf._.composite_rgb_17, xcf._.composite_rgb_17, xcf._.composite_indexed_00 ; Burn
|
||||||
|
.p18 dd 18, xcf._.composite_rgb_18, xcf._.composite_rgb_18, xcf._.composite_indexed_00 ; Hard Light
|
||||||
|
.p19 dd 19, xcf._.composite_rgb_05, xcf._.composite_rgb_05, xcf._.composite_indexed_00 ; Soft Light : XCF >= 2 only ('soft light' == 'overlay')
|
||||||
|
.p20 dd 20, xcf._.composite_rgb_20, xcf._.composite_rgb_20, xcf._.composite_indexed_00 ; Grain Extract : XCF >= 2 only
|
||||||
|
.p21 dd 21, xcf._.composite_rgb_21, xcf._.composite_rgb_21, xcf._.composite_indexed_00 ; Grain Merge : XCF >= 2 only
|
||||||
|
xcf._.composite_table.end:
|
@@ -1,3 +1,22 @@
|
|||||||
|
;;================================================================================================;;
|
||||||
|
;;//// blend_mmx.asm //// (c) dunkaist, 2011-2012 ////////////////////////////////////////////////;;
|
||||||
|
;;================================================================================================;;
|
||||||
|
;; ;;
|
||||||
|
;; 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/>. ;;
|
||||||
|
;; ;;
|
||||||
|
;;================================================================================================;;
|
||||||
|
|
||||||
proc xcf._.blend_rgb
|
proc xcf._.blend_rgb
|
||||||
|
|
||||||
xchg al, bh
|
xchg al, bh
|
@@ -1,3 +1,22 @@
|
|||||||
|
;;================================================================================================;;
|
||||||
|
;;//// blend_sse.asm //// (c) dunkaist, 2011-2012 ////////////////////////////////////////////////;;
|
||||||
|
;;================================================================================================;;
|
||||||
|
;; ;;
|
||||||
|
;; 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/>. ;;
|
||||||
|
;; ;;
|
||||||
|
;;================================================================================================;;
|
||||||
|
|
||||||
proc xcf._.blend_rgb
|
proc xcf._.blend_rgb
|
||||||
|
|
||||||
push eax ebx
|
push eax ebx
|
@@ -22,14 +22,14 @@ format MS COFF
|
|||||||
|
|
||||||
public @EXPORT as 'EXPORTS'
|
public @EXPORT as 'EXPORTS'
|
||||||
|
|
||||||
include '../../../../struct.inc'
|
include 'struct.inc'
|
||||||
include '../../../../proc32.inc'
|
include 'proc32.inc'
|
||||||
include '../../../../macros.inc'
|
include 'macros.inc'
|
||||||
include '../../../../config.inc'
|
include 'config.inc'
|
||||||
include '../../../../debug-fdo.inc'
|
include 'debug-fdo.inc'
|
||||||
__DEBUG__ = 0
|
__DEBUG__ = 0
|
||||||
__DEBUG_LEVEL__ = 1
|
__DEBUG_LEVEL__ = 1
|
||||||
include '../../../../develop/libraries/libs-dev/libio/libio.inc'
|
include 'libio.inc'
|
||||||
purge section,mov,add,sub
|
purge section,mov,add,sub
|
||||||
|
|
||||||
include 'libimg.inc'
|
include 'libimg.inc'
|
||||||
@@ -53,6 +53,11 @@ include 'xbm/xbm.asm'
|
|||||||
include 'scale.asm'
|
include 'scale.asm'
|
||||||
include 'convert.asm'
|
include 'convert.asm'
|
||||||
|
|
||||||
|
COMPOSITE_MODE equ MMX
|
||||||
|
; MMX | pretty fast and compatible
|
||||||
|
; SSE | a bit faster, but may be unsupported by some CPUs
|
||||||
|
include 'blend.asm'
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
proc lib_init ;///////////////////////////////////////////////////////////////////////////////////;;
|
proc lib_init ;///////////////////////////////////////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
@@ -2743,6 +2748,7 @@ img._.get_scanline_len: ;///////////////////////////////////////////////////////
|
|||||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
|
|
||||||
|
section '.data' data readable writable align 16
|
||||||
;include_debug_strings
|
;include_debug_strings
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
@@ -2807,6 +2813,7 @@ export \
|
|||||||
img.scale , 'img_scale' , \
|
img.scale , 'img_scale' , \
|
||||||
img.get_scaled_size, 'img_get_scaled_size', \
|
img.get_scaled_size, 'img_get_scaled_size', \
|
||||||
img.convert , 'img_convert' , \
|
img.convert , 'img_convert' , \
|
||||||
|
img.blend , 'img_blend' , \
|
||||||
img.formats_table , 'img_formats_table'
|
img.formats_table , 'img_formats_table'
|
||||||
|
|
||||||
; import from deflate unpacker
|
; import from deflate unpacker
|
||||||
@@ -2841,7 +2848,6 @@ gif_default_palette:
|
|||||||
db 0, 0, 0
|
db 0, 0, 0
|
||||||
db 0xFF, 0xFF, 0xFF
|
db 0xFF, 0xFF, 0xFF
|
||||||
|
|
||||||
section '.data' data readable writable align 16
|
|
||||||
; uninitialized data - global constant tables
|
; uninitialized data - global constant tables
|
||||||
mem.alloc dd ?
|
mem.alloc dd ?
|
||||||
mem.free dd ?
|
mem.free dd ?
|
||||||
|
@@ -29,10 +29,6 @@
|
|||||||
include 'xcf.inc'
|
include 'xcf.inc'
|
||||||
;include '../../../../../system/board/trunk/debug.inc'
|
;include '../../../../../system/board/trunk/debug.inc'
|
||||||
|
|
||||||
COMPOSITE_MODE equ MMX
|
|
||||||
; MMX | pretty fast and compatible
|
|
||||||
; SSE | a bit faster, but may be unsupported by some CPUs
|
|
||||||
|
|
||||||
MAX_LAYERS = 255
|
MAX_LAYERS = 255
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
@@ -1616,10 +1612,6 @@ endl
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
|
|
||||||
match =MMX, COMPOSITE_MODE{include 'composite_mmx.asm'}
|
|
||||||
match =SSE, COMPOSITE_MODE{include 'composite_sse.asm'}
|
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
@@ -1636,28 +1628,3 @@ xcf._.prop_table_begin:
|
|||||||
dd 11, xcf._.parse_properties.11
|
dd 11, xcf._.parse_properties.11
|
||||||
dd 15, xcf._.parse_properties.15
|
dd 15, xcf._.parse_properties.15
|
||||||
xcf._.prop_table_end:
|
xcf._.prop_table_end:
|
||||||
|
|
||||||
xcf._.composite_table.begin:
|
|
||||||
.p00 dd 00, xcf._.composite_rgb_00, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Normal
|
|
||||||
.p01 dd 01, xcf._.composite_rgb_01, xcf._.composite_gray_01, xcf._.composite_gray_01 ; Dissolve : random dithering to discrete alpha
|
|
||||||
; .p02 dd 02, xcf._.composite_rgb_02, 0, xcf._.composite_indexed_02 ; Behind : not selectable in the GIMP UI. not implemented
|
|
||||||
.p03 dd 03, xcf._.composite_rgb_03, xcf._.composite_rgb_03, xcf._.composite_indexed_00 ; Multiply
|
|
||||||
.p04 dd 04, xcf._.composite_rgb_04, xcf._.composite_rgb_04, xcf._.composite_indexed_00 ; Screen
|
|
||||||
.p05 dd 05, xcf._.composite_rgb_05, xcf._.composite_rgb_05, xcf._.composite_indexed_00 ; Overlay
|
|
||||||
.p06 dd 06, xcf._.composite_rgb_06, xcf._.composite_rgb_06, xcf._.composite_indexed_00 ; Difference
|
|
||||||
.p07 dd 07, xcf._.composite_rgb_07, xcf._.composite_rgb_07, xcf._.composite_indexed_00 ; Addition
|
|
||||||
.p08 dd 08, xcf._.composite_rgb_08, xcf._.composite_rgb_08, xcf._.composite_indexed_00 ; Subtract
|
|
||||||
.p09 dd 09, xcf._.composite_rgb_09, xcf._.composite_rgb_09, xcf._.composite_indexed_00 ; Darken Only
|
|
||||||
.p10 dd 10, xcf._.composite_rgb_10, xcf._.composite_rgb_10, xcf._.composite_indexed_00 ; Lighten Only
|
|
||||||
.p11 dd 11, xcf._.composite_rgb_11, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Hue (H of HSV)
|
|
||||||
.p12 dd 12, xcf._.composite_rgb_12, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Saturation (S of HSV)
|
|
||||||
.p13 dd 13, xcf._.composite_rgb_13, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Color (H and S of HSL)
|
|
||||||
.p14 dd 14, xcf._.composite_rgb_14, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Value (V of HSV)
|
|
||||||
.p15 dd 15, xcf._.composite_rgb_15, xcf._.composite_rgb_15, xcf._.composite_indexed_00 ; Divide
|
|
||||||
.p16 dd 16, xcf._.composite_rgb_16, xcf._.composite_rgb_16, xcf._.composite_indexed_00 ; Dodge
|
|
||||||
.p17 dd 17, xcf._.composite_rgb_17, xcf._.composite_rgb_17, xcf._.composite_indexed_00 ; Burn
|
|
||||||
.p18 dd 18, xcf._.composite_rgb_18, xcf._.composite_rgb_18, xcf._.composite_indexed_00 ; Hard Light
|
|
||||||
.p19 dd 19, xcf._.composite_rgb_05, xcf._.composite_rgb_05, xcf._.composite_indexed_00 ; Soft Light : XCF >= 2 only ('soft light' == 'overlay')
|
|
||||||
.p20 dd 20, xcf._.composite_rgb_20, xcf._.composite_rgb_20, xcf._.composite_indexed_00 ; Grain Extract : XCF >= 2 only
|
|
||||||
.p21 dd 21, xcf._.composite_rgb_21, xcf._.composite_rgb_21, xcf._.composite_indexed_00 ; Grain Merge : XCF >= 2 only
|
|
||||||
xcf._.composite_table.end:
|
|
||||||
|
Reference in New Issue
Block a user