1 # This file is a Tcl script to test out the "photo" image type and the
2 # other procedures in the file tkImgPhoto.c. It is organized in the
3 # standard fashion for Tcl tests.
5 # Copyright (c) 1994 The Australian National University
6 # Copyright (c) 1994-1997 Sun Microsystems, Inc.
7 # Copyright (c) 1998-1999 by Scriptics Corporation.
10 # Author: Paul Mackerras (paulus@cs.anu.edu.au)
14 package require tcltest 2.1
15 namespace import -force tcltest::configure
16 namespace import -force tcltest::testsDirectory
17 configure -testdir [file join [pwd] [file dirname [info script]]]
18 configure -loadfile [file join [testsDirectory] constraints.tcl]
19 tcltest::loadTestedCommands
21 namespace import -force tcltest::makeFile
22 namespace import -force tcltest::removeFile
24 eval image delete [image names]
30 set README [makeFile {
31 README -- Tk test suite design document.
34 # find the teapot.ppm file for use in these tests
35 # first look in $tk_library/demos/images/teapot.ppm
36 # then look in <this file>/../../library/demos/images/teapot.ppm
37 testConstraint hasTeapotPhoto 1
38 set teapotPhotoFile [file join $tk_library demos images teapot.ppm]
39 if {![file exists $teapotPhotoFile]} {
40 set newLib [file dirname [testsDirectory]]
41 set teapotPhotoFile [file join $newLib library demos images teapot.ppm]
42 if {![file exists $teapotPhotoFile]} {
43 testConstraint hasTeapotPhoto
47 test imgPhoto-1.1 {options for photo images} {
48 image create photo p1 -width 79 -height 83
49 list [lindex [p1 configure -width] 4] [lindex [p1 configure -height] 4] \
50 [image width p1] [image height p1]
52 test imgPhoto-1.2 {options for photo images} {
53 list [catch {image create photo p1 -file no.such.file} err] \
55 } {1 {couldn't open "no.such.file": no such file or directory}}
56 test imgPhoto-1.3 {options for photo images} hasTeapotPhoto {
57 list [catch {image create photo p1 -file $teapotPhotoFile \
58 -format no.such.format} err] $err
59 } {1 {image file format "no.such.format" is not supported}}
60 test imgPhoto-1.4 {options for photo images} hasTeapotPhoto {
61 image create photo p1 -file $teapotPhotoFile
62 list [image width p1] [image height p1]
64 test imgPhoto-1.5 {options for photo images} hasTeapotPhoto {
65 image create photo p1 -file $teapotPhotoFile \
66 -format ppm -width 79 -height 83
67 list [image width p1] [image height p1] \
68 [lindex [p1 configure -file] 4] [lindex [p1 configure -format] 4]
69 } [list 79 83 $teapotPhotoFile ppm]
70 test imgPhoto-1.6 {options for photo images} {
71 image create photo p1 -palette 2/2/2 -gamma 2.2
72 list [format %.1f [lindex [p1 configure -gamma] 4]] \
73 [lindex [p1 configure -palette] 4]
75 test imgPhoto-1.7 {options for photo images} {
76 list [catch {image create photo p1 -file $README} err] $err
77 } [subst {1 {couldn't recognize data in image file "$README"}}]
78 test imgPhoto-1.8 {options for photo images} {
79 list [catch {image create photo -blah blah} err] $err
80 } {1 {unknown option "-blah"}}
81 test imgPhoto-1.9 {options for photo images - error case} {
82 list [catch {image create photo -format} err] $err
83 } {1 {value for "-format" missing}}
84 test imgPhoto-1.10 {options for photo images - error case} {
85 list [catch {image create photo -data} err] $err
86 } {1 {value for "-data" missing}}
87 test imgPhoto-1.11 {options for photo images - error case} {
88 list [catch {image create photo p1 -format} err] $err
89 } {1 {value for "-format" missing}}
91 test imgPhoto-2.1 {ImgPhotoCreate procedure} {
92 eval image delete [image names]
93 catch {image create photo -blah blah}
96 test imgPhoto-2.2 {ImgPhotoCreate procedure} {
97 eval image delete [image names]
98 image create photo image1
99 list [info commands image1] [image names] \
100 [image width image1] [image height image1]
101 } {image1 image1 0 0}
102 # test imgPhoto-2.3 {ImgPhotoCreate procedure: creation failure} {
103 # image create photo p1
104 # image create photo p2 -width 10 -height 10
105 # catch {image create photo p2 -file bogus.img} msg
108 # } {couldn't open "bogus.img": no such file or directory}
110 test imgPhoto-3.1 {ImgPhotoConfigureMaster procedure} hasTeapotPhoto {
111 image create photo p1 -file $teapotPhotoFile
112 p1 configure -file $teapotPhotoFile
114 test imgPhoto-3.2 {ImgPhotoConfigureMaster procedure} hasTeapotPhoto {
115 image create photo p1 -file $teapotPhotoFile
116 list [catch {p1 configure -file bogus} err] [string tolower $err] \
117 [image width p1] [image height p1]
118 } {1 {couldn't open "bogus": no such file or directory} 256 256}
119 test imgPhoto-3.3 {ImgPhotoConfigureMaster procedure} hasTeapotPhoto {
120 image create photo p1
121 .c create image 10 10 -image p1 -tags p1.1 -anchor nw
122 .c create image 300 10 -image p1 -tags p1.2 -anchor nw
124 p1 configure -file $teapotPhotoFile
126 list [image width p1] [image height p1] [.c bbox p1.1] [.c bbox p1.2]
127 } {256 256 {10 10 266 266} {300 10 556 266}}
129 eval image delete [image names]
130 image create photo p1
131 .c create image 10 10 -image p1
134 test imgPhoto-4.1 {ImgPhotoCmd procedure} {
135 list [catch {p1} err] $err
136 } {1 {wrong # args: should be "p1 option ?arg arg ...?"}}
137 test imgPhoto-4.2 {ImgPhotoCmd procedure} {
138 list [catch {p1 blah} err] $err
139 } {1 {bad option "blah": must be blank, cget, configure, copy, data, get, put, read, redither, transparency, or write}}
140 test imgPhoto-4.3 {ImgPhotoCmd procedure: blank option} {
142 list [catch {p1 blank x} err] $err
143 } {1 {wrong # args: should be "p1 blank"}}
144 test imgPhoto-4.4 {ImgPhotoCmd procedure: cget option} {
145 list [catch {p1 cget} msg] $msg
146 } {1 {wrong # args: should be "p1 cget option"}}
147 test imgPhoto-4.5 {ImgPhotoCmd procedure: cget option} {
148 image create photo p2 -width 25 -height 30
149 list [p2 cget -width] [p2 cget -height]
151 test imgPhoto-4.6 {ImgPhotoCmd procedure: configure option} {
152 llength [p1 configure]
154 test imgPhoto-4.7 {ImgPhotoCmd procedure: configure option} {
155 p1 conf -palette 3/4/2
156 p1 configure -palette
157 } {-palette {} {} {} 3/4/2}
158 test imgPhoto-4.8 {ImgPhotoCmd procedure: configure option} {
159 list [catch {p1 configure -blah} msg] $msg
160 } {1 {unknown option "-blah"}}
161 test imgPhoto-4.9 {ImgPhotoCmd procedure: configure option} {
162 list [catch {p1 configure -palette {} -gamma} msg] $msg
163 } {1 {value for "-gamma" missing}}
164 test imgPhoto-4.10 {ImgPhotoCmd procedure: copy option} hasTeapotPhoto {
165 image create photo p2 -file $teapotPhotoFile
166 p1 configure -width 0 -height 0 -palette {} -gamma 1
168 list [image width p1] [image height p1] [p1 get 100 100]
169 } {256 256 {169 117 90}}
170 test imgPhoto-4.11 {ImgPhotoCmd procedure: copy option} {
171 list [catch {p1 copy} msg] $msg
172 } {1 {wrong # args: should be "p1 copy source-image ?-compositingrule rule? ?-from x1 y1 x2 y2? ?-to x1 y1 x2 y2? ?-zoom x y? ?-subsample x y?"}}
173 test imgPhoto-4.12 {ImgPhotoCmd procedure: copy option} {
174 list [catch {p1 copy blah} msg] $msg
175 } {1 {image "blah" doesn't exist or is not a photo image}}
176 test imgPhoto-4.13 {ImgPhotoCmd procedure: copy option} {
177 list [catch {p1 copy p2 -blah} msg] $msg
178 } {1 {unrecognized option "-blah": must be -compositingrule, -from, -shrink, -subsample, -to, or -zoom}}
179 test imgPhoto-4.14 {ImgPhotoCmd procedure: copy option} {
180 list [catch {p1 copy p2 -from -to} msg] $msg
181 } {1 {the "-from" option requires one to four integer values}}
182 test imgPhoto-4.15 {ImgPhotoCmd procedure: copy option} {
184 p1 copy p2 -from 0 70 60 120 -shrink
185 list [image width p1] [image height p1] [p1 get 20 10]
186 } {60 50 {215 154 120}}
187 test imgPhoto-4.16 {ImgPhotoCmd procedure: copy option} {
188 p1 copy p2 -from 60 120 0 70 -to 20 50
189 list [image width p1] [image height p1] [p1 get 40 80]
190 } {80 100 {19 92 192}}
191 test imgPhoto-4.17 {ImgPhotoCmd procedure: copy option} {
192 p1 copy p2 -from 0 120 60 70 -to 0 0 100 100
193 list [image width p1] [image height p1] [p1 get 80 60]
194 } {100 100 {215 154 120}}
195 test imgPhoto-4.18 {ImgPhotoCmd procedure: copy option} {
196 p1 copy p2 -from 60 70 0 120 -zoom 2
197 list [image width p1] [image height p1] [p1 get 100 50]
198 } {120 100 {169 99 47}}
199 test imgPhoto-4.19 {ImgPhotoCmd procedure: copy option} {
200 p1 copy p2 -from 0 70 60 120
201 list [image width p1] [image height p1] [p1 get 100 50]
202 } {120 100 {169 99 47}}
203 test imgPhoto-4.20 {ImgPhotoCmd procedure: copy option} {
204 p1 copy p2 -from 20 20 200 180 -subsample 2 -shrink
205 list [image width p1] [image height p1] [p1 get 50 30]
206 } {90 80 {207 146 112}}
207 test imgPhoto-4.21 {ImgPhotoCmd procedure: copy option} {
209 set result [list [image width p1] [image height p1]]
210 p1 conf -width 49 -height 51
211 lappend result [image width p1] [image height p1]
213 lappend result [image width p1] [image height p1]
214 p1 copy p2 -from 0 0 10 10 -shrink
215 lappend result [image width p1] [image height p1]
217 p1 copy p2 -from 0 0 10 10 -shrink
218 lappend result [image width p1] [image height p1]
220 p1 copy p2 -from 0 0 10 10 -shrink
221 lappend result [image width p1] [image height p1]
222 } {256 256 49 51 49 51 49 51 10 51 10 10}
223 test imgPhoto-4.22 {ImgPhotoCmd procedure: get option} hasTeapotPhoto {
224 p1 read $teapotPhotoFile
225 list [p1 get 100 100] [p1 get 150 100] [p1 get 100 150]
226 } {{169 117 90} {172 115 84} {35 35 35}}
227 test imgPhoto-4.23 {ImgPhotoCmd procedure: get option} {
228 list [catch {p1 get 256 0} err] $err
229 } {1 {p1 get: coordinates out of range}}
230 test imgPhoto-4.24 {ImgPhotoCmd procedure: get option} {
231 list [catch {p1 get 0 -1} err] $err
232 } {1 {p1 get: coordinates out of range}}
233 test imgPhoto-4.25 {ImgPhotoCmd procedure: get option} {
234 list [catch {p1 get} err] $err
235 } {1 {wrong # args: should be "p1 get x y"}}
236 test imgPhoto-4.26 {ImgPhotoCmd procedure: put option} {
237 list [catch {p1 put} err] $err
238 } {1 {wrong # args: should be "p1 put data ?options?"}}
239 test imgPhoto-4.27 {ImgPhotoCmd procedure: put option} {
240 list [catch {p1 put {{white} {white white}}} err] $err
241 } {1 {all elements of color list must have the same number of elements}}
242 test imgPhoto-4.28 {ImgPhotoCmd procedure: put option} {
243 list [catch {p1 put {{blahgle}}} err] $err
244 } {1 {can't parse color "blahgle"}}
245 test imgPhoto-4.29 {ImgPhotoCmd procedure: put option} {
246 p1 put -to 10 10 20 20 {{white}}
249 test imgPhoto-4.30 {ImgPhotoCmd procedure: read option} {
250 list [catch {p1 read} err] $err
251 } {1 {wrong # args: should be "p1 read fileName ?options?"}}
252 test imgPhoto-4.31 {ImgPhotoCmd procedure: read option} hasTeapotPhoto {
253 list [catch {p1 read $teapotPhotoFile -zoom 2} err] $err
254 } {1 {unrecognized option "-zoom": must be -format, -from, -shrink, or -to}}
255 test imgPhoto-4.32 {ImgPhotoCmd procedure: read option} {
256 list [catch {p1 read bogus} err] [string tolower $err]
257 } {1 {couldn't open "bogus": no such file or directory}}
258 test imgPhoto-4.33 {ImgPhotoCmd procedure: read option} hasTeapotPhoto {
259 list [catch {p1 read $teapotPhotoFile -format bogus} err] $err
260 } {1 {image file format "bogus" is not supported}}
261 test imgPhoto-4.34 {ImgPhotoCmd procedure: read option} {
262 list [catch {p1 read $README} err] $err
263 } [subst {1 {couldn't recognize data in image file "$README"}}]
264 test imgPhoto-4.35 {ImgPhotoCmd procedure: read option} hasTeapotPhoto {
265 p1 read $teapotPhotoFile
266 list [image width p1] [image height p1] [p1 get 120 120]
267 } {256 256 {161 109 82}}
268 test imgPhoto-4.36 {ImgPhotoCmd procedure: read option} hasTeapotPhoto {
269 p1 read $teapotPhotoFile -from 0 70 60 120 -to 10 10 -shrink
270 list [image width p1] [image height p1] [p1 get 29 19]
271 } {70 60 {244 180 144}}
272 test imgPhoto-4.37 {ImgPhotoCmd procedure: redither option} {
274 list [catch {p1 redither x} err] $err
275 } {1 {wrong # args: should be "p1 redither"}}
276 test imgPhoto-4.38 {ImgPhotoCmd procedure: write option} {
277 list [catch {p1 write} err] $err
278 } {1 {wrong # args: should be "p1 write fileName ?options?"}}
279 test imgPhoto-4.39 {ImgPhotoCmd procedure: write option} {
280 list [catch {p1 write teapot.tmp -format bogus} err] $err
281 } {1 {image file format "bogus" is unknown}}
282 eval image delete [image names]
283 image create photo p1
284 test imgPhoto-4.40 {ImgPhotoCmd procedure: transparency option} {
285 list [catch {p1 transparency} err] $err
286 } {1 {wrong # args: should be "p1 transparency option ?arg arg ...?"}}
287 test imgPhoto-4.41 {ImgPhotoCmd procedure: transparency get option} {
288 list [catch {p1 transparency get} err] $err
289 } {1 {wrong # args: should be "p1 transparency get x y"}}
290 test imgPhoto-4.42 {ImgPhotoCmd procedure: transparency get option} {
291 list [catch {p1 transparency get 0} err] $err
292 } {1 {wrong # args: should be "p1 transparency get x y"}}
293 test imgPhoto-4.43 {ImgPhotoCmd procedure: transparency get option} {
294 list [catch {p1 transparency get 0 0 0} err] $err
295 } {1 {wrong # args: should be "p1 transparency get x y"}}
296 test imgPhoto-4.44 {ImgPhotoCmd procedure: transparency get option} {
297 list [catch {p1 transparency get bogus 0} err] $err
298 } {1 {expected integer but got "bogus"}}
299 test imgPhoto-4.45 {ImgPhotoCmd procedure: transparency get option} {
300 list [catch {p1 transparency get 0 bogus} err] $err
301 } {1 {expected integer but got "bogus"}}
302 test imgPhoto-4.46 {ImgPhotoCmd procedure: transparency get option} {
304 p1 transparency get 0 0
306 test imgPhoto-4.47 {ImgPhotoCmd procedure: transparency get option} {
307 list [catch {p1 transparency get 1 0} err] $err
308 } {1 {p1 transparency get: coordinates out of range}}
309 test imgPhoto-4.48 {ImgPhotoCmd procedure: transparency get option} {
310 list [catch {p1 transparency get -1 0} err] $err
311 } {1 {p1 transparency get: coordinates out of range}}
312 test imgPhoto-4.49 {ImgPhotoCmd procedure: transparency get option} {
313 list [catch {p1 transparency get 0 1} err] $err
314 } {1 {p1 transparency get: coordinates out of range}}
315 test imgPhoto-4.50 {ImgPhotoCmd procedure: transparency get option} {
316 list [catch {p1 transparency get 0 -1} err] $err
317 } {1 {p1 transparency get: coordinates out of range}}
318 test imgPhoto-4.51 {ImgPhotoCmd procedure: transparency get option} {
320 p1 transparency get 0 0
322 test imgPhoto-4.52 {ImgPhotoCmd procedure: transparency set option} {
323 list [catch {p1 transparency set} err] $err
324 } {1 {wrong # args: should be "p1 transparency set x y boolean"}}
325 test imgPhoto-4.53 {ImgPhotoCmd procedure: transparency set option} {
326 list [catch {p1 transparency set 0} err] $err
327 } {1 {wrong # args: should be "p1 transparency set x y boolean"}}
328 test imgPhoto-4.54 {ImgPhotoCmd procedure: transparency set option} {
329 list [catch {p1 transparency set 0 0} err] $err
330 } {1 {wrong # args: should be "p1 transparency set x y boolean"}}
331 test imgPhoto-4.55 {ImgPhotoCmd procedure: transparency set option} {
332 list [catch {p1 transparency set 0 0 0 0} err] $err
333 } {1 {wrong # args: should be "p1 transparency set x y boolean"}}
334 test imgPhoto-4.56 {ImgPhotoCmd procedure: transparency set option} {
335 list [catch {p1 transparency set bogus 0 0} err] $err
336 } {1 {expected integer but got "bogus"}}
337 test imgPhoto-4.57 {ImgPhotoCmd procedure: transparency set option} {
338 list [catch {p1 transparency set 0 bogus 0} err] $err
339 } {1 {expected integer but got "bogus"}}
340 test imgPhoto-4.58 {ImgPhotoCmd procedure: transparency set option} {
341 list [catch {p1 transparency set 0 0 bogus} err] $err
342 } {1 {expected boolean value but got "bogus"}}
343 test imgPhoto-4.59 {ImgPhotoCmd procedure: transparency set option} {
344 list [catch {p1 transparency set 1 0 0} err] $err
345 } {1 {p1 transparency set: coordinates out of range}}
346 test imgPhoto-4.60 {ImgPhotoCmd procedure: transparency set option} {
347 list [catch {p1 transparency set -1 0 0} err] $err
348 } {1 {p1 transparency set: coordinates out of range}}
349 test imgPhoto-4.61 {ImgPhotoCmd procedure: transparency set option} {
350 list [catch {p1 transparency set 0 1 0} err] $err
351 } {1 {p1 transparency set: coordinates out of range}}
352 test imgPhoto-4.62 {ImgPhotoCmd procedure: transparency set option} {
353 list [catch {p1 transparency set 0 -1 0} err] $err
354 } {1 {p1 transparency set: coordinates out of range}}
355 test imgPhoto-4.63 {ImgPhotoCmd procedure: transparency set option} {
356 p1 transparency set 0 0 false
357 p1 transparency get 0 0
359 test imgPhoto-4.64 {ImgPhotoCmd procedure: transparency set option} {
360 p1 transparency set 0 0 true
361 p1 transparency get 0 0
363 # Now for some heftier testing, checking that setting and resetting of
364 # pixels' transparency status doesn't "leak" with any one-off errors.
365 proc checkImgTrans {img width height} {
367 for {set x 0} {$x<$width} {incr x} {
368 for {set y 0} {$y<$height} {incr y} {
369 if {[$img transparency get $x $y]} {
376 test imgPhoto-4.65 {ImgPhotoCmd procedure: transparency get option} {
377 p1 put white -to 0 0 3 3
380 test imgPhoto-4.66 {ImgPhotoCmd procedure: transparency get option} {
383 } {0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2}
384 proc checkImgTransLoopSetReset {img width height} {
386 for {set x 0} {$x<$width} {incr x} {
387 for {set y 0} {$y<$height} {incr y} {
388 $img put white -to 0 0 3 3
389 $img transparency set $x $y 1
390 set result [concat $result [checkImgTrans $img $width $height]]
392 $img transparency set $x $y 0
393 set result [concat $result [checkImgTrans $img $width $height]]
399 test imgPhoto-4.67 {ImgPhotoCmd procedure: transparency set option} {
400 checkImgTransLoopSetReset p1 3 3
401 } {0 0 , . 0 1 , . 0 2 , . 1 0 , . 1 1 , . 1 2 , . 2 0 , . 2 1 , . 2 2 , .}
402 proc checkImgTransLoopResetSet {img width height} {
404 for {set x 0} {$x<$width} {incr x} {
405 for {set y 0} {$y<$height} {incr y} {
407 $img transparency set $x $y 0
408 set result [concat $result [checkImgTrans $img $width $height]]
410 $img transparency set $x $y 1
411 set result [concat $result [checkImgTrans $img $width $height]]
417 test imgPhoto-4.68 {ImgPhotoCmd procedure: transparency set option} {
418 checkImgTransLoopResetSet p1 3 3
419 } {0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 2 1 0 1 1 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 1 0 1 1 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 1 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 1 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 1 1 2 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 .}
420 catch {rename checkImgTransLoopSetReset {}}
421 catch {rename checkImgTransLoopResetSet {}}
422 # Test the compositing rules for copying images
423 image create photo p1 -width 3 -height 3
424 image create photo p2 -width 2 -height 2
425 test imgPhoto-4.68 {ImgPhotoCmd procedure: copy with -compositingrule} {
426 list [catch {p1 copy p2 -to 1 1 -compositingrule} msg] $msg
427 } {1 {the "-compositingrule" option requires a value}}
428 test imgPhoto-4.69 {ImgPhotoCmd procedure: copy with -compositingrule} {
429 list [catch {p1 copy p2 -to 1 1 -compositingrule BAD} msg] $msg
430 } {1 {bad compositing rule "BAD": must be overlay or set}}
431 test imgPhoto-4.70 {ImgPhotoCmd procedure: copy with -compositingrule} {
432 # Tests default compositing rule
435 p1 put white -to 0 0 2 2
436 p2 put white -to 0 0 2 2
437 p2 transparency set 0 0 true
441 test imgPhoto-4.71 {ImgPhotoCmd procedure: copy with -compositingrule} {
444 p1 put white -to 0 0 2 2
445 p2 put white -to 0 0 2 2
446 p2 transparency set 0 0 true
447 p1 copy p2 -to 1 1 -compositingrule overlay
450 test imgPhoto-4.72 {ImgPhotoCmd procedure: copy with -compositingrule} {
453 p1 put white -to 0 0 2 2
454 p2 put white -to 0 0 2 2
455 p2 transparency set 0 0 true
456 p1 copy p2 -to 1 1 -compositingrule set
459 catch {rename checkImgTrans {}}
461 test imgPhoto-5.1 {ImgPhotoGet/Free procedures, shared instances} hasTeapotPhoto {
462 eval image delete [image names]
464 image create photo p1 -file $teapotPhotoFile
465 .c create image 0 0 -image p1 -tags p1.1
466 .c create image 256 0 -image p1 -tags p1.2
467 .c create image 0 256 -image p1 -tags p1.3
470 p1 configure -width 1
473 p1 configure -height 1
478 test imgPhoto-6.1 {ImgPhotoDisplay procedure, blank display} {
480 image create photo p1 -width 10 -height 10
482 .c create image 10 10 -image p1
486 test imgPhoto-7.1 {ImgPhotoFree procedure, resource freeing} hasTeapotPhoto {
487 eval image delete [image names]
489 image create photo p1 -file $teapotPhotoFile
490 .c create image 0 0 -image p1 -anchor nw
495 test imgPhoto-7.2 {ImgPhotoFree procedures, unlinking} hasTeapotPhoto {
496 image create photo p1 -file $teapotPhotoFile
497 .c create image 10 10 -image p1 -anchor nw
511 test imgPhoto-7.3 {ImgPhotoFree procedures, multiple visuals} hasTeapotPhoto {
512 image create photo p1 -file $teapotPhotoFile
514 frame .f -visual best
515 button .f.b2 -image p1
521 .f.b2 configure -image {}
527 test imgPhoto-8.1 {ImgPhotoDelete procedure} hasTeapotPhoto {
528 image create photo p2 -file $teapotPhotoFile
531 test imagePhoto-8.2 {ImgPhotoDelete procedure} hasTeapotPhoto {
532 image create photo p2 -file $teapotPhotoFile
534 set x [list [info command p2] [info command new*] [newp2 cget -file]]
536 append x [info command new*]
537 } [list {} newp2 $teapotPhotoFile]
538 test imagePhoto-8.3 {ImgPhotoDelete procedure, name cleanup} {
539 image create photo p1
540 image create photo p2 -width 10 -height 10
542 list [catch {p1 copy p2} msg] $msg
543 } {1 {image "p2" doesn't exist or is not a photo image}}
545 test imagePhoto-9.1 {ImgPhotoCmdDeletedProc procedure} hasTeapotPhoto {
546 image create photo p2 -file $teapotPhotoFile
548 list [lsearch -exact [image names] p2] [catch {p2 foo} msg] $msg
549 } {-1 1 {invalid command name "p2"}}
551 test imgPhoto-10.1 {Tk_ImgPhotoPutBlock procedure} {
552 eval image delete [image names]
553 image create photo p1
554 p1 put {{#ff0000 #ff0000 #ff0000 #ff0000 #ff0000 #ff0000 #ff0000 #ff0000}} -to 0 0
555 p1 put {{#00ff00 #00ff00}} -to 2 0
556 list [p1 get 2 0] [p1 get 3 0] [p1 get 4 0]
557 } {{0 255 0} {0 255 0} {255 0 0}}
559 test imgPhoto-11.1 {Tk_FindPhoto} {
560 eval image delete [image names]
561 image create bitmap i1
562 image create photo p1
563 list [catch {p1 copy i1} msg] $msg
564 } {1 {image "i1" doesn't exist or is not a photo image}}
566 test imgPhoto-12.1 {Tk_PhotoPutZoomedBlock} hasTeapotPhoto {
567 image create photo p3 -file $teapotPhotoFile
568 set result [list [p3 get 50 50] [p3 get 100 100]]
570 lappend result [image width p3] [image height p3] [p3 get 100 100]
573 } {{19 92 192} {169 117 90} 512 512 {19 92 192}}
575 test imgPhoto-13.1 {check separation of images in different interpreters} {
576 eval image delete [image names]
578 R0lGODlhQgBkAPUAANbWxs7Wxs7OxsbOxsbGxsbGvb3Gvca9vcDAwL21vbW1vbW1tbWtta2t
579 ta2ltaWltaWlraWctaWcrZycrZyUrZSUrZSMrZSMpYyMrYyMpYyEpYSEpYR7pYR7nHp7pYRz
580 pYRynHtzpXtznHtrnHNrnHNjnGtjnGtjlGtalGNalGNSlGNSjFpSlFpKlFpKjFJKjFJCjFI5
581 jEo5jEo5hEoxhEIxhDkphDkhhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAQgBkAAAG
582 /kCEcEgsGo/IpHLJbDqf0Kh0Sq1ar9isdsvter/gsHhMLpvP6LR6zW673/C4fE6v2+/4vH7P
583 7/v/gIGCg4SFhoeIiYqLjI2Oj5CRkpOUlZaXmJmOBZxXnAQEnKIIBUQJCguoDKkIBgWhpUev
584 CA4TDwgEUpwKERUaHCIiJCQjIiEUQhwqKiwqLjDQMCwoIha3oUO5ESMuLSwtLSIMsU4Tzi4o
585 JBwWFA8ODQo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EBdtKzBfbQWlhMHoHIXBnvABBGE9UMKNMKhgQgnG
600 nNQO0wVQoI4FEohFyr9GzDIYaaPxxWy0rCjKQJUMQvxBaMOgNMQChcU4DAkZ6PoV/hIUoP4i
601 Z7g/YHZHIPXeyWyONgsaCi4AOoLjXP8uhAAvPpCQ2Akr38UpXW60Ij8yPkMmwwj8KAI8QWtQ
602 +eXSixEb37WhcHQBERz2rdZ8leCBBcXNY3XevQ8VG/6+F5CACDYgATlmYYD27aRmLngBNADC
603 GGxxQEAWUJDzqpcctc2DARN4kNRgtJxhnKAFV0kIEhYAJ34IQwUhqkENYFCCE5BmGf9wwWmA
604 5UGgXAAVtfCFMIgRLMbFLQIPYFACcMI7TjQoH2eJQIs2poEMYMAp5XGAvFrBCYS9ImzQG1vT
605 arGTEQhIhE7QjLA+MKDOxClGwuoJtWi0uBIUIxjDSE2wQ4iHl7ywQDjGwZws/NcAlgBjaKQJ
606 JDVuoQBeUeACoFkMcFqgQL1IgxpRSsjsqHA/gy0tHvmAx2z2BxIupaJrnVxCEAAAOw==
612 x1 eval [list image create photo T1_data -data $data]
613 x2 eval [list image create photo T1_data -data $data]
620 test imgPhoto-14.1 {GIF writes work correctly} {
621 set data "R0lGODlhYwA5APcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgAysnGy8hKzM
622 hASs3MTcjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
623 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
624 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
625 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
626 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
627 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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ovbv37+BzBgEEADs=
646 set photo [image create photo -data $data]
647 set filename [makeFile {} imgPhoto-14.1.gif]
648 removeFile imgPhoto-14.1.gif
649 $photo write $filename -format gif
650 set photo2 [image create photo -file $filename]
651 set result [string equal [$photo data] [$photo2 data]]
652 image delete $photo $photo2
653 catch {file delete -force $filename}
657 test imgPhoto-15.1 {photo images can fail to allocate memory gracefully} \
659 # This is not portable to very large machines with more around
660 # 3GB of free memory available...
661 list [catch {image create photo -width 32000 -height 32000} msg] $msg
662 } {1 {not enough free memory for image buffer}}
665 eval image delete [image names]
668 removeFile README-imgPhoto
669 ::tcltest::cleanupTests