nop has asked for the wisdom of the Perl Monks concerning the following question:
But I can seem to load images from a data string (as the images will eventually be pulled from a database). That is, this doesn't work:use strict; use Tk; use Tk::JPEG; my $fname = "rock.jpg"; my $win = new MainWindow; my $image = $win->Photo('-format' => 'jpeg', '-file' => $fname); $win->Label(-image=>$image)->pack; MainLoop;
It dies with this error:use strict; use Tk; use Tk::JPEG; my $fname = "rock.jpg"; open(F, $fname) or die "cant open $fname"; binmode(F); undef $/; my $jpeg = <F>; close(F); my $win = new MainWindow; my $image = $win->Photo('-format' => 'jpeg', '-data' => $jpeg); $win->Label(-image=>$image)->pack; MainLoop;
Can anyone offer advice? Am I reading the JPEG in wrong, or am I sending it to TK wrong?couldn't recognize image data at C:/Perl/site/lib/Tk/Image.pm line 21.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(crazyinsomniac) Re: Win32 Tk JPEG from memory problem
by crazyinsomniac (Prior) on Nov 11, 2001 at 14:23 UTC |