- Timestamp:
- Jan 16, 2011, 10:09:17 AM (14 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/videopreview.tcl
r2028 r2035 246 246 set _movie [Rappture::Video $type $data] 247 247 file delete $fname 248 set _framerate [${_movie} getframerate]248 set _framerate [${_movie} framerate] 249 249 set _mspf [expr round(((1.0/${_framerate})*1000))] 250 250 set _delay [expr {${_mspf} - ${_ofrd}}] … … 265 265 } 266 266 267 set _lastFrame [$ _movieget position end]267 set _lastFrame [${_movie} get position end] 268 268 269 269 # update the dial with video information … … 426 426 # because the underlying c lib is too slow at reading. 427 427 $_movie seek $cur 428 $_imh put [$ _movieget image ${_width} ${_height}]428 $_imh put [${_movie} get image ${_width} ${_height}] 429 429 } 1] 430 430 regexp {(\d+\.?\d*) microseconds per iteration} ${_ofrd} match _ofrd … … 439 439 } 440 440 441 set cur [$ _movieget position cur]441 set cur [${_movie} get position cur] 442 442 443 443 # update the dial and framenum widgets … … 469 469 error "bad value: \"$val\": should be \"seek value\"" 470 470 } 471 set cur [$ _movieget position cur]471 set cur [${_movie} get position cur] 472 472 if {[string compare $cur $val] == 0} { 473 473 # already at the frame to seek to … … 478 478 479 479 # update the dial and framenum widgets 480 set _settings($this-framenum) [$ _movieget position cur]480 set _settings($this-framenum) [${_movie} get position cur] 481 481 event generate $itk_component(main) <<Frame>> 482 482 … … 505 505 # no play pending schedule one 506 506 set _pendings(play) 1 507 set _nextframe [expr {[$ _movieget position cur] + 1}]507 set _nextframe [expr {[${_movie} get position cur] + 1}] 508 508 after idle [itcl::code $this Play] 509 509 } else { -
trunk/gui/scripts/videoscreen.tcl
r2029 r2035 16 16 package require RapptureGUI 17 17 18 option add *Video.width 300widgetDefault19 option add *Video.height 300widgetDefault18 option add *Video.width -1 widgetDefault 19 option add *Video.height -1 widgetDefault 20 20 option add *Video.foreground black widgetDefault 21 21 option add *Video.controlBackground gray widgetDefault … … 70 70 private common _counters 71 71 72 private variable _width -1 ;# start x for rubberbanding73 private variable _height -1 ;# start x for rubberbanding72 private variable _width -1 ;# width of the movie 73 private variable _height -1 ;# height of the movie 74 74 private variable _movie "" ;# movie we grab images from 75 75 private variable _lastFrame 0 ;# last frame in the movie … … 120 120 121 121 itk_component add main { 122 canvas $itk_interior.main \ 123 -background black 122 canvas $itk_interior.main 124 123 } { 125 124 usual … … 128 127 bind $itk_component(main) <Configure> [itcl::code $this fixSize] 129 128 129 # setup the image display 130 130 # hold the video frames in an image on the canvas 131 131 set _imh [image create photo] 132 $itk_component(main) create image 0 0 -anchor nw -image $_imh 132 133 $itk_component(main) create image 0 0 \ 134 -anchor center \ 135 -image ${_imh} \ 136 -tags videoframe 133 137 134 138 # setup movie controls … … 311 315 312 316 itk_component add framenumlabel { 313 label $itk_component(frnumfr).framenuml -text "Frame:" -font $fg\317 label $itk_component(frnumfr).framenuml -text "Frame:" -font "arial 9" \ 314 318 -highlightthickness 0 315 319 } { … … 376 380 1,3 $itk_component(seekforward) -padx {4 0} \ 377 381 1,4 $itk_component(loop) -padx {4 0} \ 378 2,0 $itk_component(frnumfr) -padx { 20} -columnspan 3 \382 2,0 $itk_component(frnumfr) -padx {0 0} -columnspan 3 \ 379 383 2,3 $itk_component(speed) -padx {2 0} -columnspan 2 380 384 … … 392 396 393 397 eval itk_initialize $args 398 399 $itk_component(main) configure -background black 394 400 } 395 401 … … 404 410 405 411 406 if {[info exists _imh] } {412 if {[info exists _imh] && ("" != ${_imh})} { 407 413 image delete ${_imh} 408 414 set _imh "" … … 466 472 itcl::body Rappture::VideoScreen::load {type data} { 467 473 474 video stop 475 468 476 # open the file 469 477 set fname "" … … 493 501 } 494 502 495 video stop496 497 503 if {"file" == $type} { 498 504 if {("" != [info commands ${_movie}])} { … … 502 508 # if they are different, close the old movie 503 509 # and clear out all old drawings from the canvas. 504 set err [catch {${_movie} getfilename} filename]510 set err [catch {${_movie} filename} filename] 505 511 if {($err == 0)&& ($data == $filename)} { 506 512 # video file already open, don't reopen it. … … 509 515 # clear the old movie 510 516 ${_movie} release 517 set _width -1 518 set _height -1 511 519 512 520 # delete drawings objects from canvas … … 520 528 file delete $fname 521 529 } 522 set _framerate [${_movie} getframerate]530 set _framerate [${_movie} framerate] 523 531 video speed 524 525 video seek 0 526 527 # update the dial and framenum widgets 528 set _settings(framenum) 0 529 530 531 # setup the image display 532 533 foreach {w h} [query dimensions] break 534 if {${_width} == -1} { 535 set _width $w 536 } 537 if {${_height} == -1} { 538 set _height $h 539 } 540 541 set _lastFrame [$_movie get position end] 532 puts stderr "framerate: ${_framerate}" 533 534 set _lastFrame [${_movie} get position end] 542 535 543 536 # update the dial with video information … … 559 552 560 553 fixSize 554 555 # goto the first frame 556 # update the dial and framenum widgets 557 video seek 0 558 set _settings(framenum) 0 561 559 } 562 560 … … 600 598 } 601 599 602 # set _width [winfo width $itk_component(main)] 603 # set _height [winfo height $itk_component(main)] 604 # 605 # # get an image with the new size 606 # ${_imh} put [${_movie} get image ${_width} ${_height}] 607 # 608 # # fix the dimesions of the canvas 609 # #$itk_component(main) configure -width ${_width} -height ${_height} 610 # 611 # $itk_component(main) configure -scrollregion [$itk_component(main) bbox all] 612 613 ###################### 600 # get dimensions for the new image 601 # adjust the aspect ratio, if necessary 602 603 puts stderr "aspect ratio: [query aspectratio]" 604 605 foreach {w h} [query dimensions] break 606 foreach {num den} [query aspectratio] break 607 608 if {[expr 1.0*$w/$h] != [expr 1.0*$num/$den]} { 609 # we need to adjust the frame height and width 610 # to keep the correct aspect ratio 611 # hold the height constant, 612 # adjust the width as close as we can 613 # to the correct aspect ratio 614 set w [expr int(1.0*$num/$den*$h)] 615 } 616 617 if {-1 == ${_width}} { 618 set _width $w 619 } 620 if {-1 == ${_height}} { 621 set _height $h 622 } 614 623 615 624 # get an image with the new size 625 ${_imh} blank 626 ${_imh} configure -width 1 -height 1 627 ${_imh} configure -width 0 -height 0 616 628 ${_imh} put [${_movie} get image ${_width} ${_height}] 617 puts stderr "${_width} ${_height}" 618 619 # fix the dimesions of the video canvas 620 $itk_component(main) configure -width ${_width} -height ${_height} 629 630 # place the image in the center of the canvas 631 set ccw [winfo width $itk_component(main)] 632 set cch [winfo height $itk_component(main)] 633 $itk_component(main) coords videoframe [expr $ccw/2.0] [expr $cch/2.0] 634 635 puts stderr "----------------------------" 636 puts stderr "adjusted = $w $h" 637 puts stderr "data = ${_width} ${_height}" 638 puts stderr "image = [image width ${_imh}] [image height ${_imh}]" 639 foreach {x0 y0 x1 y1} [$itk_component(main) bbox videoframe] break 640 puts stderr "bbox = $x0 $y0 $x1 $y1" 641 puts stderr "ccw cch = [expr $ccw/2.0] [expr $cch/2.0]" 642 puts stderr "main = [winfo width $itk_component(main)] [winfo height $itk_component(main)]" 643 puts stderr "hull = [winfo width $itk_component(hull)] [winfo height $itk_component(hull)]" 621 644 } 622 645 … … 670 693 set ret "" 671 694 switch -- $type { 695 "aspectratio" { 696 set ret [${_movie} aspect display] 697 } 672 698 "dimensions" { 673 699 set ret [${_movie} size] … … 698 724 # not the current frame+1. this happens when we skip frames 699 725 # because the underlying c lib is too slow at reading. 700 $ _movieseek $cur701 $ _imh put [$_movieget image ${_width} ${_height}]726 ${_movie} seek $cur 727 ${_imh} put [${_movie} get image ${_width} ${_height}] 702 728 } 1] 703 729 regexp {(\d+\.?\d*) microseconds per iteration} ${_ofrd} match _ofrd … … 712 738 } 713 739 714 set cur [$ _movieget position cur]740 set cur [${_movie} get position cur] 715 741 716 742 # update the dial and framenum widgets … … 751 777 error "bad value: \"$val\": should be \"seek value\"" 752 778 } 753 set cur [$ _movieget position cur]779 set cur [${_movie} get position cur] 754 780 if {[string compare $cur $val] == 0} { 755 781 # already at the frame to seek to … … 761 787 762 788 # update the dial and framenum widgets 763 set _settings(framenum) [$ _movieget position cur]789 set _settings(framenum) [${_movie} get position cur] 764 790 event generate $itk_component(main) <<Frame>> 765 791 … … 790 816 # no play pending schedule one 791 817 set _pendings(play) 1 792 set _nextframe [expr {[$ _movieget position cur] + 1}]818 set _nextframe [expr {[${_movie} get position cur] + 1}] 793 819 after idle [itcl::code $this Play] 794 820 } else { … … 1217 1243 $itk_component(dialminor) loop disable 1218 1244 } else { 1219 set cur [$ _movieget position cur]1220 set end [$ _movieget position end]1245 set cur [${_movie} get position cur] 1246 set end [${_movie} get position end] 1221 1247 1222 1248 set startframe [expr $cur-10] … … 1236 1262 1237 1263 # ---------------------------------------------------------------------- 1238 # OPTION: -width 1264 # OPTION: -width - width of the video 1239 1265 # ---------------------------------------------------------------------- 1240 1266 itcl::configbody Rappture::VideoScreen::width { … … 1248 1274 1249 1275 # ---------------------------------------------------------------------- 1250 # OPTION: -height 1276 # OPTION: -height - height of the video 1251 1277 # ---------------------------------------------------------------------- 1252 1278 itcl::configbody Rappture::VideoScreen::height {
Note: See TracChangeset
for help on using the changeset viewer.