1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
package require Tk
package require img::sun
puts "Using [expr $tcl_platform(pointerSize) *8]-bit Tcl [info patchlevel], Tk $::tk_patchLevel, img::sun [package require img::sun]"
catch { file mkdir testOut }
set imgFile [file join ".." "sourceimgs" "tree.ras"]
# Read a SUN raster file into a photo images.
set imgRGBA [image create photo -file $imgFile]
# Read a SUN raster file into a photo image using option "-withalpha 0".
set imgRGB [image create photo -file $imgFile -format [list SUN -matte 0 -verbose true]]
# Write SUN raster RGBA file using different -compression and -withalpha option values.
set row 0
foreach withalpha [list 0 1] {
foreach compr [list "none" "rle"] {
set outFile [file join "testOut" "sun-compr-${compr}-alpha-${withalpha}.rgba"]
$imgRGBA write $outFile -format [list SUN -compression $compr -withalpha $withalpha -verbose ON]
set img(rgba-$compr-$withalpha) [image create photo -file $outFile]
label .img(rgba-$compr-$withalpha) -image $img(rgba-$compr-$withalpha) -compound top -relief ridge \
-text "rgba -compression $compr -withalpha $withalpha"
grid .img(rgba-$compr-$withalpha) -row $row -column 0 -padx 2 -pady 4 -sticky ew
incr row
}
}
# Write SUN raster RGB file using different -compression and -withalpha option values.
set row 0
foreach withalpha [list 0 1] {
foreach compr [list "none" "rle"] {
set outFile [file join "testOut" "sun-compr-${compr}-alpha-${withalpha}.rgb"]
$imgRGB write $outFile -format [list SUN -compression $compr -withalpha $withalpha -verbose 1]
set img(rgb-$compr-$withalpha) [image create photo -file $outFile]
label .img(rgb-$compr-$withalpha) -image $img(rgb-$compr-$withalpha) -compound top -relief ridge \
-text "rgb -compression $compr -withalpha $withalpha"
grid .img(rgb-$compr-$withalpha) -row $row -column 1 -padx 2 -pady 4 -sticky ew
incr row
}
}
bind . <Escape> exit
if { [lindex $argv 0] eq "auto" } {
update
after 500
exit
}
|