Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
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 have tried multiple image formats without success. 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?Code: Select all
<?
$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 degrees
if ($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 entry
imagecolortransparent($outimg, $black);
imagetruecolortopalette($outimg, 0, 256);
// Output it
header("Content-type: image/gif");
imageGIF($outimg);
imagedestroy($outimg);
?>feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]