Leser: 16
1 2 3
our $image = $window->Photo('-format' => 'jpeg', '-file' => $bgimage, '-height' => $height, '-width' => $width); our $background = $window->Label ( '-image' => $image, '-height' => $height, '-width' => $width); $background->pack('-ipadx' => $width, '-ipady' => $height);
$background->pack('-fill' => 'both');
2010-08-01T02:21:04 conrayNun die Frage: geht das überhaupt so einfach ?
Falls nicht wie kann ich es dann scalieren so dass wenn das bild zb nict breit genug ist dann 2mal nebeneinander ausgegeben wird?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#!/usr/bin/perl use strict; use warnings; use MIME::Base64; use Imager; use Tk; use Tk::PNG; # load image: my $img = Imager->new(file => 'test.png') or die Imager->errstr; # tk window: my $mw = tkinit(-title => 'Imager & Tk::Photo'); my $img_lab = $mw->Label( -image => my $photo = $mw->Photo, )->pack( -fill => 'both', -expand => 1, ); # react on resize: $img_lab->bind( '<Configure>' => sub { my $new_img = $img->scale( xpixels => $img_lab->width, ypixels => $img_lab->height, type => 'nonprop', ); $new_img->write( data => \my $data, type => 'png', ) or die $new_img->errstr; $photo->configure(data => encode_base64($data)); }, ); $mw->geometry("=200x200"); MainLoop;