hardburn has asked for the wisdom of the Perl Monks concerning the following question:
I have a PNG that I want to put on an SDL::Surface. Before placing it, it needs to be rotated an arbitrary number of degrees. What I have so far:
sub _make_surface { my $self = shift; my $img = Image::Magick->new(); $img->Read( $self->{sprite} ); $img->AffineTransform( rotate => $self->{move_angle}, ); my $img_data = ''; open( my $sh, '>', \$img_data ) or die "Can't open filehandle to scalar: $!\n"; $img->Write( file => $sh, filename => 'img.png', ); close $sh; return SDL::Surface->new( -from => $img_data, ); }
The problem is that the resulting image doesn't show up. You just see a single black pixel where the center of the picture is supposed to be.
I'm not stuck on using Image::Magick. GD or any other image processor will work. GD would be nicer because you can get the image data directly (no mucking about with IO::Scalar), but it doesn't appear to have a method for rotating an arbitrary number of degrees. I would prefer to keep everything in memory rather than doing file IO.
"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Rotating an Image for an SDL::Surface
by BrowserUk (Patriarch) on Aug 19, 2005 at 00:26 UTC | |
by hardburn (Abbot) on Aug 19, 2005 at 03:07 UTC | |
|
Re: Rotating an Image for an SDL::Surface
by zentara (Cardinal) on Aug 19, 2005 at 11:56 UTC |