Jump to content


Image Rotation

  • Please log in to reply
No replies to this topic

#1 sdmers

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 01 April 2006 - 09:02 AM

I have a graphic that is hexagonal in shape (like a stop sign - actually a 6 sided map tile). It can be rotated in any of the 6 orientations. When I execute the code below, I get my tile rotated perfectly and the transparency as I want it. However, I also get a dark, almost black line down the left hand side of the image. I believe I have narrowed the problem down to the imagetruecolortopalette function call, but I need that in order to display the image as a GIF with transparency. Any thoughts?

$tile=$_GET['i']; // Tile name
$rotationangle=$_GET['r']; // Rotation angle (0=0, 1=60, 2=120, etc.)
$img = imagecreatefrompng($tile.".png");

// Rotate the true color image
$Rotatedimg = imagerotate($img, $rotationangle*60, 0);

// Offset the image by some amount if it is rotated 60, 120, 240 or 300 degrees
if ($rotationangle==0 || $rotationangle==3)

// Copy and create the transparent color (black)
$outimg = imagecreatetruecolor($w, $h);
$black = imagecolorallocate($outimg, 0, 0, 0); // resolve given palette entry
imagecolortransparent($outimg, $black);
imagetruecolortopalette($outimg, 0, 256);

// Output it
header("Content-type: image/gif");

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users