source pkgsNeeded.tcl

ui_init "t_blend.tcl"
SetFileTypes

PH "Image blending with Tcl functions"

proc warpfunct1 { x y } {
    set nx [expr $x - 0.2*$y]
    set ny $y
    return [list $nx $ny]
}

proc warpfunct2 { x y } {
    set nx [expr $x + 0.2*$y]
    set ny $y
    return [list $nx $ny]
}

proc warpderiv { x y } {
    set ux 1
    set uy 1
    set vx 1
    set vy 1
    return [list $ux $uy $vx $vy]
}

proc blendfunct { x y } {
    set f $x
    return [list $f]
}

set srcimg1 [poImgUtil ReadImg "testIn/alexa.gif"]
$srcimg1 GetImageInfo w h a g

set srcimg2 [poImgUtil ReadImgScaled "testIn/keksi$fInfo(suf)" $w $h] 
set dstimg  [poImage NewImage $w $h $a $g]

set msg "Original image1"
ui_addimg $srcimg1 $msg
set msg "Original image2"
ui_addimg $srcimg2 $msg

set fname "testOut/blendFunc$fInfo(suf)"
set msg   "$fname: Blending with Tcl functions"
P $msg
$dstimg BlendFunct $srcimg1 $srcimg2 \
	warpfunct1 warpderiv warpfunct2 warpderiv blendfunct 3 1
$dstimg WriteSimple $fname $fInfo(fmt) $fInfo(vsn)
ui_addimg $dstimg $msg

PS
P "End of test"

ui_show

if { [lindex $argv 0] eq "auto" } {
    ui_exit
    exit 0
}
