Il Tue, 9 Dec 2003 18:35:40 +0100 Carsten Zandecki <service@xxxxxxxxxxxxx> ha
scritto:
Hello,
> Well, thanx for your help again, Mattia.
> But after testing a lot ,
> i found out that Wx::Image->SetData(); doesen't handle binary data
> correctly
> ...
>
> This is my code :
>
> # CODE SNIPPED START
>
> my $file='hoe.bmp';
If this is a standard Windows bitmap file, well, ->SetData() is not supposed
to handle that. If it is a raw file containing *only* image data, in 24-bit RGB,
then it indeed is a bug. In the latter case *please* send a complete bugreport,
with
the sample file and a working complete program.
> my $img=Image::Magick->new();
> $img->Read($file);
> my ($w,$h)=$img->Get('width','height');
>
> my $data;
> my $buf;
>
> sysopen(BINDAT, $file,O_RDONLY|O_BINARY);
> while (sysread(BINDAT, $buf, 1024)) { $data .= $buf;}
> close(BINDAT);
>
> $this->{image}=Wx::Image->new($w,$h);
> $this->{image}->SetData($data);
> $this->{bmphandler}=Wx::Bitmap->new($this->{image});
> if($this->{bmphandler}->Ok)
> { $this->{currentBitmap}->SetBitmap($this->{bmphandler}); }
>
> # CODE SNIPPET END
This is how SetData is supposed to be used:
# creates a red image
my $image = Wx::Image->new( 50, 50 );
my $data = "\xff\x00\x00" x ( 50 * 50 );
$image->SetData( $data );
> It results in corrupt data. An expample output can be seen here :
> http://www.mediaminds.de/error.htm
>
> My System :
> ActivePerl 5.6.1 ( 635 )
> Windows XP Professional
> Tested with wxPerl 0.16 and wxPerl 0.18 ( No Unicode )
Regards
Mattia
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
|