Any of the Perl gui modules, Tk, Gtk2, Wx, etc will let you do it. Here is one of many variants on the theme. The idea( in Tk terminology) is to load your image into a Photo object, then update one of many widgets that will accept a Photo.....buttons..labels..a canvas, etc. You can get more advanced, and make your images dynamically from some data, or you can use a Canvas to plot your data, and update it (see second example). First example is a slideshow of all jpgs in a directory.

Otherwise, be more specific in what you want to visualize, or show a sample code of your ChartDirector, showing how it outputs images. If it can write to an inline scalar, that would make it easy, as you can then avoid making temp images files.

#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Photo; use Tk::JPEG; #this one stores the photo objects in a hash my (%img_obj, @keys, $image); my $count = 0; my $main = new MainWindow; &load_images; my $imglab = $main->Label( -height => 600, -width => 600, -image => $image )->pack; my $label = $main->Label()->pack; my $label2 = $main->Label()->pack; my $button1 = $main->Button( -text => 'faster', -command => \&faster )->pack; my $button2 = $main->Button( -text => 'slower', -command => \&slower)->pack; my $rpt = 400; my $min = 60; # increase this if it starts to freeze at fastest + setting my $max = 5000; # increase if you want more time per image my $incdec = 20; # default 50ms increase/decrease my $time_this = $main->repeat( $rpt, \&show_pic ); $label2->configure( -text => $rpt ); MainLoop; sub slower { return if $rpt > $max; $rpt += $incdec; $time_this->time($rpt); $label2->configure( -text => $rpt ); } sub faster { return if $rpt < $min; $rpt -= $incdec; $time_this->time($rpt); $label2->configure( -text => $rpt ); } sub show_pic { push (@keys,shift(@keys)); #circular list $image->blank; $imglab->configure(-image => $img_obj{ $keys[0] } ); $label->configure( -text => $keys[0] ); } sub load_images { my @files = <pics/*.jpg>; foreach my $file (@files) { $img_obj{ $file } = $main->Photo( '-format' => 'jpeg', '-file' => $file); } @keys = keys %img_obj; $image = $img_obj{ $keys[0] }; } __END__
#!/usr/bin/perl use warnings; use strict; use Tk; my $w=20; my $x=0; my $y=0; my %colors = ( 0 => ['black','yellow'], 1 => ['yellow','black'], 2 => ['white','green'], 3 => ['green','white'], 4 => ['grey','red'], 5 => ['red','grey'], 6 => ['blue','white'], 7 => ['white','blue'], 8 => ['orange','grey45'], 9 => ['grey45','orange'], ); my %bardata = ( 0 => rand 200, 1 => rand 200, 2 => rand 200, 3 => rand 200, 4 => rand 200, 5 => rand 200, 6 => rand 200, 7 => rand 200, 8 => rand 200, 9 => rand 200, ); my %bars; my $mw=tkinit; my $c = $mw->Canvas->pack; for (0..9) { $bars{$_} = $c->createRectangle($x,$y,$x+20,$bardata{$_}, -fill=> ${$colors{$_}}[0], ); my $text = $c->createText($x+10,$y+10, -anchor=>'center', -fill => ${$colors{$_}}[1], -text => $_ ); $x+=20; } $mw->Button( -text => "Save", -command => [sub { $c->update; my @capture=(); my ($x0,$y0,$x1,$y1)=$c->bbox('all'); @capture=('-x'=>$x0,'-y'=>$y0,-height=>$y1-$y0,-width=>$x1-$x +0); $c -> postscript(-colormode=>'color', -file=>$0.'.ps', -rotate=>90, -width=>800, -height=>500, @capture); } ] )->pack; $mw->repeat(200, sub{ &update }); MainLoop; ########################################################## sub update{ $x=0; $y=0; %bardata = ( 0 => rand 200, 1 => rand 200, 2 => rand 200, 3 => rand 200, 4 => rand 200, 5 => rand 200, 6 => rand 200, 7 => rand 200, 8 => rand 200, 9 => rand 200, ); for (0..9) { $c->delete( $bars{$_} ); $bars{$_} = $c->createRectangle($x,$y,$x+20,$bardata{$_}, -fill=> ${$colors{$_}}[0], ); my $text = $c->createText($x+10,$y+10, -anchor=>'center', -fill => ${$colors{$_}}[1], -text => $_ ); $x+=20; } } __END__

I'm not really a human, but I play one on earth Remember How Lucky You Are

In reply to Re: image viewer (mildly OT) by zentara
in thread image viewer (mildly OT) by hill

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.