sdmers Posted April 1, 2006 Share Posted April 1, 2006 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");$w=imagesx($img);$h=imagesy($img);// 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 degreesif ($rotationangle==0 || $rotationangle==3) {$xoffset=0;$yoffset=0;}else {$xoffset=60;$yoffset=35;}// Copy and create the transparent color (black)$outimg = imagecreatetruecolor($w, $h);imagecopyresampled($outimg,$Rotatedimg,0,0,$xoffset,$yoffset,$w,$h,$w,$h);$black = imagecolorallocate($outimg, 0, 0, 0); // resolve given palette entryimagecolortransparent($outimg, $black);imagetruecolortopalette($outimg, 0, 256);// Output itheader("Content-type: image/gif");imageGIF($outimg);imagedestroy($outimg);?> Link to comment https://forums.phpfreaks.com/topic/6323-image-rotation/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.