in reply to Re^3: Bitmap for beginners (Perl Tk)
in thread Bitmap for beginners (Perl Tk)
Hi mawe,
OK - so I tried this:
use Tk;
my $top = new MainWindow;
my $pic = $top->Photo(-file=>encode_photo_data("up.bmp"));
$top->Button(-image=>$pic)->pack();
MainLoop();
sub encode_photo_data {
my($file) = @_;
use MIME::Base64;
my ($bin, $data, $stat);
open PHOTO, $file or die "Cannot open $file: $!";
while ( $stat = sysread PHOTO, $bin, 57 * 17 ) {
$data .= encode_base64($bin);
}
close PHOTO or die $!;
die "sysread error: $!" unless defined $stat;
$data;
} # end encode_photo_data
now it returns 'Cannot open + a lot of binary data...?
What am I doing wrong?