From: Bradley K. E. <bk...@bk...> - 2006-09-18 04:59:31
|
Hello All, I have a scalar containing a bmp (generated by ChartDirector (http://www.advsofteng.com/cdperl.html)) that I would like to create a Wx::Bitmap from, which I will then draw on a panel. Wx::Bitmap does not seem to be able to do this directly, but I thought I could create a Wx::Bitmap from a Wx::Image. So code looks like: # create a scalar containing the bmp data my $chart_bmp = $chart_object->makeChart2($perlchartdir::BMP); my $bmp = Wx::Bitmap->new( Wx::Image->new( ... ) ); The ... is where I am having problems. I've tried the following forms of the Wx::Image constructor: Wx::Image->new( width, height, data ): my $bmp = Wx::Bitmap->new( Wx::Image->new( 200, 200, $chart_bmp ) ); Gives me an error message of 'not enough data in image constructor at ...'. Wx::Image->new( stream, type, index ): First naive attempt: $bmp = Wx::Bitmap->new( Wx::Image->new( $chart_bmp, wxBITMAP_TYPE_BMP, -1 ) ); Gives me an error message indicating the file does not exist so I assume the constructor thinks that $chart_bmp is a file name. Next attempt: $bmp = Wx::Bitmap->new( Wx::Image->new( \$chart_bmp, wxBITMAP_TYPE_BMP, -1 ) ); Which gives an error message that it is not a GLOB reference. So stream == filehandle. But the point of this is that I don't want to write $chart_bmp to a file, so I tried opening $chart_bmp as an "in memory" file: open my $fh, '<', \$chart_bmp or die "cannot open: $!"; $bmp = Wx::Bitmap->new( Wx::Image->new( $fh, wxBITMAP_TYPE_BMP, -1 ) ); Which gives me an error of 'DIB Header: Image width > 32767 pixels for file.'. I've tested the contents of $chart_bmp by opening a filehandle and printing the contents to the file and it is a valid bitmap. So I am a bit lost as far as where to go next. Is it possible to create a stream from a scalar? I've looked at wxInputStream but the docs indicate that it is not implemented in wxPerl. Am I am being a complete moron and missing something obvious here? Any help/pointers would be greatly appreciated. Thanks, Brad |
From: Mattia B. <mat...@li...> - 2006-09-18 19:00:53
|
On Sun, 17 Sep 2006 21:58:56 -0700 "Bradley K. Embree" <bk...@bk...> wrote: Hi, > I have a scalar containing a bmp (generated by ChartDirector > (http://www.advsofteng.com/cdperl.html)) that I would like to create a > Wx::Bitmap from, which I will then draw on a panel. > > Wx::Bitmap does not seem to be able to do this directly, but I thought I > could create a Wx::Bitmap from a Wx::Image. Correct. > open my $fh, '<', \$chart_bmp or die "cannot open: $!"; > $bmp = Wx::Bitmap->new( > Wx::Image->new( $fh, wxBITMAP_TYPE_BMP, -1 ) > ); > > Which gives me an error of 'DIB Header: Image width > 32767 pixels for > file.'. This should work, though. I will have a look at it. Which wxPerl/wxWidgets versions and platform are you using? > I've tested the contents of $chart_bmp by opening a filehandle and > printing the contents to the file and it is a valid bitmap. So I am a > bit lost as far as where to go next. > > Is it possible to create a stream from a scalar? I've looked at > wxInputStream but the docs indicate that it is not implemented in wxPerl. Perl strams should be transparently wrapped into wxInputStreams. Regards Mattia |
From: Bradley K. E. <bk...@bk...> - 2006-09-19 03:35:21
|
Mattia Barbon wrote: > On Sun, 17 Sep 2006 21:58:56 -0700 > "Bradley K. Embree" <bk...@bk...> wrote: > > Hi, > >> open my $fh, '<', \$chart_bmp or die "cannot open: $!"; >> $bmp = Wx::Bitmap->new( >> Wx::Image->new( $fh, wxBITMAP_TYPE_BMP, -1 ) >> ); >> >> Which gives me an error of 'DIB Header: Image width > 32767 pixels for >> file.'. > > This should work, though. I will have a look at it. > Which wxPerl/wxWidgets versions and platform are you using? > OS: Windows 2000 SP4 Perl: v5.8.7 built for MSWin32-x86-multi-thread Binary build 815 [211909] provided by ActiveState wxPerl: 0.5 installed from www.gigi.co.uk. wxWidgets: 2.6.3 I installed the latest perl from ActiveState (5.8.8 build 819) and got the same error message using wxPerl 0.5. I then installed the latest wxPerl PPMs (compiled against wxWidgets 2.7.0) from www.gigi.co.uk and got the same error: wxPerl: 0.56 wxWidgets: 2.7.0 I plan on getting my Ubuntu machine up and running so I can test on there as well, and will let you know the results. Thanks Mattia, Brad |
From: Bradley K. E. <bk...@bk...> - 2006-09-20 04:05:33
Attachments:
Ubuntu-Perl.txt
Win2K-Perl.txt
|
Bradley K. Embree wrote: > Mattia Barbon wrote: >> On Sun, 17 Sep 2006 21:58:56 -0700 >> "Bradley K. Embree" <bk...@bk...> wrote: >> >> Hi, >> >>> open my $fh, '<', \$chart_bmp or die "cannot open: $!"; >>> $bmp = Wx::Bitmap->new( >>> Wx::Image->new( $fh, wxBITMAP_TYPE_BMP, -1 ) >>> ); >>> >>> Which gives me an error of 'DIB Header: Image width > 32767 pixels >>> for file.'. >> >> This should work, though. I will have a look at it. >> Which wxPerl/wxWidgets versions and platform are you using? >> > > OS: Windows 2000 SP4 > Perl: v5.8.7 built for MSWin32-x86-multi-thread > Binary build 815 [211909] provided by ActiveState > wxPerl: 0.5 installed from www.gigi.co.uk. > wxWidgets: 2.6.3 > > > I installed the latest perl from ActiveState (5.8.8 build 819) and got > the same error message using wxPerl 0.5. > > I then installed the latest wxPerl PPMs (compiled against wxWidgets > 2.7.0) from www.gigi.co.uk and got the same error: > > wxPerl: 0.56 > wxWidgets: 2.7.0 > > > I plan on getting my Ubuntu machine up and running so I can test on > there as well, and will let you know the results. I've since tried this on an Ubuntu box which also failed. I've attached the output of perl -V from both my Windows 2000 PC and my Ubuntu PC. On the Ubuntu PC I had: Alien::wxWidgets 0.21 wxPerl 0.57 wxWidgets 2.6.3 and still no luck. Not sure if that helps or not. :) Brad |
From: Mattia B. <mat...@li...> - 2006-09-22 20:19:41
|
On Tue, 19 Sep 2006 21:04:57 -0700 "Bradley K. Embree" <bk...@bk...> wrote: <snip> > I've since tried this on an Ubuntu box which also failed. I've attached > the output of perl -V from both my Windows 2000 PC and my Ubuntu PC. > > On the Ubuntu PC I had: > > Alien::wxWidgets 0.21 > wxPerl 0.57 > wxWidgets 2.6.3 > > and still no luck. Not sure if that helps or not. :) More data always helps :-) I found the bug. The quick fix is below, the full fix (rewriting cpp/stream.cpp/h) should be in wxPerl 0.58. Regards Mattia Index: cpp/streams.cpp =================================================================== RCS file: /cvsroot/wxperl/wxPerl/cpp/streams.cpp,v retrieving revision 1.14 diff -u -2 -r1.14 streams.cpp --- cpp/streams.cpp 27 Aug 2006 15:26:18 -0000 1.14 +++ cpp/streams.cpp 22 Sep 2006 20:10:27 -0000 @@ -18,8 +18,8 @@ // thread KO -const char sub_read[] = "sub { sysread $_[0], $_[1], $_[2] }"; -const char sub_seek[] = "sub { sysseek $_[0], $_[1], $_[2] }"; -const char sub_tell[] = "sub { sysseek $_[0], 0, 1 }"; -const char sub_write[] = "sub { syswrite $_[0], $_[1] }"; +const char sub_read[] = "sub { read $_[0], $_[1], $_[2] }"; +const char sub_seek[] = "sub { seek $_[0], $_[1], $_[2] }"; +const char sub_tell[] = "sub { seek $_[0], 0, 1 }"; +const char sub_write[] = "sub { print { $_[0] } $_[1] }"; const char sub_length[] = "sub { ( stat $_[0] )[7] }"; |
From: Mattia B. <mat...@li...> - 2006-09-24 15:45:02
|
On Fri, 22 Sep 2006 22:20:13 +0200 Mattia Barbon <mat...@li...> wrote: > On Tue, 19 Sep 2006 21:04:57 -0700 > "Bradley K. Embree" <bk...@bk...> wrote: > More data always helps :-) I found the bug. The quick fix is below, > the full fix (rewriting cpp/stream.cpp/h) should be in wxPerl 0.58. Quick-fix now in CVS. Regards Mattia |