Changeset 193 for trunk/gui/scripts/imageresult.tcl
- Timestamp:
- Feb 19, 2006, 8:10:19 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/imageresult.tcl
r132 r193 14 14 package require Itk 15 15 package require BLT 16 package require Img 16 17 17 18 option add *ImageResult.width 3i widgetDefault … … 56 57 public method delete {args} 57 58 public method scale {args} 58 public method download { }59 public method download {option} 59 60 60 61 protected method _rebuild {args} … … 289 290 290 291 # ---------------------------------------------------------------------- 291 # USAGE: download 292 # USAGE: download coming 293 # USAGE: download now 292 294 # 293 295 # Clients use this method to create a downloadable representation … … 296 298 # "string" is the data itself. 297 299 # ---------------------------------------------------------------------- 298 itcl::body Rappture::ImageResult::download {} { 299 set top [_topimage] 300 if {$top == ""} { 301 return "" 302 } 303 return [list jpg [image data $top -format jpg]] 300 itcl::body Rappture::ImageResult::download {option} { 301 switch $option { 302 coming { 303 # nothing to do 304 } 305 now { 306 set top [_topimage] 307 if {$top == ""} { 308 return "" 309 } 310 311 # 312 # Hack alert! Need data in binary format, 313 # so we'll save to a file and read it back. 314 # 315 set tmpfile /tmp/image[pid].jpg 316 $top write $tmpfile -format jpeg 317 set fid [open $tmpfile r] 318 fconfigure $fid -encoding binary -translation binary 319 set bytes [read $fid] 320 close $fid 321 file delete -force $tmpfile 322 323 return [list .jpg $bytes] 324 } 325 default { 326 error "bad option \"$option\": should be coming, now" 327 } 328 } 304 329 } 305 330
Note: See TracChangeset
for help on using the changeset viewer.