1
我使用這個代碼:如何保留透明度在PHP GD上PNG
<?php
list($width, $height, $type, $attr) = getimagesize("terrain.png");
$canvas = imagecreatetruecolor($width, $height);
$src = imagecreatefrompng("terrain.png");
if($_GET['glass'] == 1){
$src2 = imagecreatefrompng("rock.png");
}
imagecopymerge($canvas, $src, 0, 0, 0, 0, $width, $height, 100);
if($_GET['glass'] == 1){
imagecopy($canvas, $src2, 0, 0, 0, 0, 16, 16);
}
imagealphablending($canvas, true);
imagesavealpha($canvas, true);
header("Content-type: image/png");
imagepng($canvas);
imagedestroy($dest);
imagedestroy($src);
?>
Terrain.png爲http://hogofwar.co.uk/experiment/mc/terrain.png(這是透明的)
使用GD時,如何保持透明度?
不工作目前 因爲我可以解決。 – Hogofwar 2010-09-19 14:59:59
你檢查了鏈接到Yogesh在答案結尾處指定的文檔嗎? – mfolnovich 2010-09-19 17:54:43