I've been asking a few questions regarding Tk lately, and once again, this has to do with Tk.
I have a lot of GIF images, and they all are displayed as buttons. To view them in a matrix of 4x4, they are all resized to a certain
$MAX_HEIGHT and
$MAX_WIDTH like this:
$images[$y] = $mainframe->Photo(-file => "$file.gif");
my ($height, $width) = ($images[$y]->height, $images[$y]->widt
+h);
my $yfactor = $height/$MAX_HEIGHT;
my $xfactor = $width/$MAX_WIDTH;
my $scalefactor = $xfactor > $yfactor ? int($xfactor) : int($y
+factor);
$scalefactor +=1;
my $scaledimage = $mainframe->Photo("button$y");
$scaledimage->copy($images[$y], -subsample => $scalefactor);
$images[$y]->destroy();
this snippet of code is executed within a loop (that's why the
@images exists)...
The problem I have is that I actually want all images to have the exact same width. With this code (using
$scaledimage->copy($images[$y], -subsample => $scalefactor) it's only possible to use integers as
$scalefactor.
I know I can use PerlMagick to resize images, save them and reload them again, but that takes two more disk-actions, and the whole thing isn't that fast already.
Is is possible to scale an image in Tk with 'floats' ? Rescaling with integers makes images either large or small...
Jouke Visser, Perl 'Adept'
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.