Jump to content

imagerotate() removing transparency


patawic

Recommended Posts

Im trying to make a script that previews the level for a game, but im having issues with transparency and the rotation of each image.

 

you can see the problem here: http://beta.trackmill.com/DUI/preview/

 

here is the php file

<?php
header('Content-Type: image/png');
$image = imagecreatefrompng('images/Background.png');

function radiansToDegrees($radians)
{
    return $radians * 180 / pi();
}
$map = file_get_contents('map.txt');
$blocks = split("<obj", $map);
for($i=2; $i<count($blocks); $i++)
{
$arg = split(" ", $blocks[$i]);
$n = str_replace("n", "", str_replace("=", "", str_replace('"', "", $arg[1])));
$x = str_replace("x", "", str_replace("=", "", str_replace('"', "", $arg[2])));
$x = $x * 20 - 13;
$y = str_replace("y", "", str_replace("=", "", str_replace('"', "", $arg[3])));
$y = $y * 22 + 15;
$a = str_replace("a", "", str_replace("=", "", str_replace('"', "", $arg[4])));
$a = radiansToDegrees($a);
$t = str_replace("t", "", str_replace("=", "", str_replace('"', "", $arg[5])));
$e = str_replace("e", "", str_replace("=", "", str_replace('"', "", $arg[6])));
$f = str_replace("f", "", str_replace("=", "", str_replace('"', "", str_replace('/>', "", $arg[7]))));
$blockimage = imagecreatefrompng("images/$n.png");

$blockimage = imagerotate($blockimage, -$a, 0, 0) ;
imagealphablending($blockimage, false);
imagesavealpha($blockimage, true);

imagecopy($image, $blockimage, $x, $y, 0, 0, imagesx($blockimage), imagesy($blockimage));
//echo "$i | $n - $x - $y - $a - $t - $e - $f <br>";
}

imagepng($image);
imagedestroy($image);
?>

 

if you require the .zip containing the images etc, just reply and i will upload it as soon as possible

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.