cormanaz has asked for the wisdom of the Perl Monks concerning the following question:
I have managed to write code that will step thru and display the jpgs, but I can't quite figure out how to scale them. I think I would use the copy method along with a shrink or zoom argument. But I'm not quite proficient enough with Tk to know how to read in one image, copy it to another resized, then display the second one. Can someone help me out? Existing code is below.
TIA.....Steve
#!/usr/bin/perl -w use strict; use Tk; use Tk::JPEG; my $c; my $dir = "c:/temp"; my @fl = ("01.jpg","05.jpg"); my $main = new MainWindow; nextp(); my $nxt = $main->Button('-text' => "Next", '-command' => \&nextp)->pac +k(); $main->Button(-text => 'exit', -command => sub{destroy $main} )->pack(-anchor => 'e'); MainLoop; sub loadpic { my $filename = shift; my $size; my $orientation; $main -> Photo('img', -file => $filename); my ($h,$w) = ($main->height, $main->width); # # how to scale the pic? # $c = $main->Label('-image' => 'img')->pack; return; } sub nextp { my $f = shift(@fl); loadpic("$dir/$f"); return; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk sizing a pic to fit a window
by zentara (Cardinal) on Mar 19, 2006 at 00:20 UTC | |
by cormanaz (Deacon) on Mar 19, 2006 at 19:56 UTC | |
|
Re: Tk sizing a pic to fit a window
by hesco (Deacon) on Mar 18, 2006 at 20:34 UTC |