in reply to Rotating an Image for an SDL::Surface

Something like this ought to do it.

Update: Fixed a couple of typos. And, having defined VERSION_33 in an arbitrary place in GD.xs and re-built GD, it now works.

#! perl -slw use strict; use GD; our $A ||= 45; my $imgIn = GD::Image->new( $ARGV[ 0 ] ) or die $!; my $cx = int $imgIn->width / 2; my $cy = int $imgIn->height /2; my $imgOut = GD::Image->new( $imgIn->getBounds, 1 ); $imgOut->copyRotated( $imgIn, $cx, $cy, 0, 0, $imgIn->getBounds, $A ); (my $ofile = $ARGV[0]) =~s[(\..*?$)][.r$A$1]; open OUT, '>:raw', $ofile or die $!; print OUT $imgOut->png; close OUT; system $ofile;

However, despite having installed the latest versions of GD(2.28) and libgd (2.0.33), running this dies with

libgd 2.0.33 or higher required for copyRotated support at ...

which is coming from gd.xs

void gdcopyRotated(dst,src,dstX,dstY,srcX,srcY,srcW,srcH,angle) GD::Image dst GD::Imagesrc double dstX double dstY int srcX int srcY int srcW int srcH int angle PROTOTYPE: $$$$$$$$$ CODE: { #ifdef VERSION_33 gdImageCopyRotated(dst,src,dstX,dstY,srcX,srcY,srcW,srcH,angle +); #else die("libgd 2.0.33 or higher required for copyRotated support") +; #endif }

but I can't work out where VERSION_33 should be defined?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

Replies are listed 'Best First'.
Re^2: Rotating an Image for an SDL::Surface
by hardburn (Abbot) on Aug 19, 2005 at 03:07 UTC

    However, despite having installed the latest versions of GD(2.28) and libgd (2.0.33) . . .

    Ahh, that was my problem. Had older versions that didn't have copyRotate().

    I ran into the same problem with VERSION_33, except I was naughtier in my solution--I put the define in gd.h (which gd.xs #include's).

    Thanks for the help.

    "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.