I have been trying to read ".png" & ".jpg" image files using "Tk::Photo".
The code works fine if I use ".xpm" or ".gif".
===================
perl -v
This is perl, v5.8.8 built for MSWin32-x86-multi-thread
(with 18 registered patches, see perl -V for more detail)
Copyright 1987-2007, Larry Wall
Binary build 822 [280952] provided by ActiveState http://www.ActiveState.com
Built Jul 31 2007 19:34:48
==============================
Here is my code
use Tk;
use warnings;
use strict;
my $mw = new MainWindow;
my $tile = $mw->Photo( -format => 'png', -file=>'Back.png');
$mw->Icon(-image => $tile);
MainLoop;
====================================
Here is what I get when I run it.
--> perl -w my_test.pl
@ 535 not utf8
SV = PV(0x241db5c) at 0x24337c4
REFCNT = 1
FLAGS = (POK,pPOK,UTF8)
PV = 0x243b03c "couldn't recognize data in image file
\"8\333A\2\1\""\0Malformed UTF-8 character (
unexpected non-continuation byte 0x41, immediately after start byte 0xdb) in
subroutine entry at C:/
PRG/Perl/lib/Tk/Image.pm line 21.
[UTF8 "couldn't recognize data in image file "8\x{0}\x{2}\x{1}""]
CUR = 45
LEN = 48
SV = PVMG(0x1db627c) at 0x24337c4
REFCNT = 1
FLAGS = (SMG,POK,pPOK,UTF8)
IV = 0
NV = 0
PV = 0x243b03c "couldn't recognize data in image file
\"8\333A\2\1\""\0Malformed UTF-8 character (
unexpected non-continuation byte 0x41, immediately after start byte 0xdb) in
subroutine entry at C:/
PRG/Perl/lib/Tk/Image.pm line 21.
[UTF8 "couldn't recognize data in image file "8\x{0}\x{2}\x{1}""]
CUR = 45
LEN = 48
MAGIC = 0x243b15c
MG_VIRTUAL = &PL_vtbl_utf8
MG_TYPE = PERL_MAGIC_utf8(w)
MG_LEN = 44
couldn't recognize data in image file "8?A " at C:/PRG/Perl/lib/Tk/Image.pm
line 21.
=================================================
Regards,
-Sean
JPEGs and PNGs have their own loaders.
You need to add....
use Tk::PNG; #and/or
use Tk::JPEG;
To your program
Jack
I had the same error, and added the line you suggest, but now get:
Fail to create pixmap with Tk_GetPixmap in ImgPhotoInstanceSetSize.
This application has requested the Runtime to terminate it in an
unusual way.
Please contact the application's support team for more information.
To avoid posting a load of source, has anyone else seen this?
Thanks
Lee
>On Jun 24, 8:31 am, "Jack D" <j...@home.net> wrote:
>> "Sean" <imfeaw5...@pacbell.net> wrote in message
>>
>> > I have been trying to read ".png" & ".jpg" image files using "Tk::Photo".
>> > The code works fine if I use ".xpm" or ".gif".
>> > Here is my code
>>
>> > use Tk;
>> > use warnings;
>> > use strict;
>> > my $mw = new MainWindow;
>> > my $tile = $mw->Photo( -format => 'png', -file=>'Back.png');
>> > $mw->Icon(-image => $tile);
>> > MainLoop;
>> > ====================================
>> [snip]
>> > couldn't recognize data in image file "8?A " at
>> > C:/PRG/Perl/lib/Tk/Image.pm line 21.
>> > =================================================
>>
>> JPEGs and PNGs have their own loaders.
>>
>> You need to add....
>>
>> use Tk::PNG; #and/or
>> use Tk::JPEG;
>>
>> To your program
>
>I had the same error, and added the line you suggest, but now get:
>
>To avoid posting a load of source, has anyone else seen this?
>
>Thanks
>Lee
I'm pretty sure your problem is that the Icon method only accepts
a gif, or bmp; NOT png nor jpg.
#!/usr/bin/perl
use Tk;
my $mw = tkinit;
my $image = 'z-icon.gif'; # 32x32 GIF or BMP
my $icon = $mw->Photo(-file => $image);
$mw->idletasks; # this line is crucial
$mw->iconimage($icon);
MainLoop;
__END__
zentara
--
I'm not really a human, but I play one on earth.
http://zentara.net/CandyGram_for_Mongo.html