File: SunWriteOptions.tcl

package info (click to toggle)
libtk-img 1%3A2.0.1%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 47,852 kB
  • sloc: ansic: 224,696; sh: 20,589; tcl: 8,921; makefile: 2,272; cpp: 1,933; ada: 1,681; pascal: 1,139; cs: 879; awk: 794; asm: 587; python: 542; xml: 95
file content (49 lines) | stat: -rwxr-xr-x 1,970 bytes parent folder | download
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
}