合并两个.png';在PHP-GD中使用透明的
将两个图像与透明部分合并会生成以下合成图像: 我想知道为什么我叠加在绿色背景上的图像的透明部分显示为这样?有人吗合并两个.png';在PHP-GD中使用透明的,php,png,gd,alphablending,Php,Png,Gd,Alphablending,将两个图像与透明部分合并会生成以下合成图像: 我想知道为什么我叠加在绿色背景上的图像的透明部分显示为这样?有人吗 $base = imagecreatefrompng('application/assets/images/vel1_bg.png'); imagealphablending($base, false); imagesavealpha($base, true); list($baseWidth, $baseHeight, $type,
$base = imagecreatefrompng('application/assets/images/vel1_bg.png');
imagealphablending($base, false);
imagesavealpha($base, true);
list($baseWidth, $baseHeight, $type, $attr) = getimagesize('application/assets/images/vel1_bg.png');
$user_board_items = $this->config->item('user_board_items');
foreach($array as $key => $value){
$item = imagecreatefrompng('application/assets/images/items/' . $user_board_items[$value[0]] . '.png');
imagealphablending($item, false);
imagesavealpha($item, true);
list($width, $height, $type, $attr) = getimagesize('application/assets/images/items/'. $user_board_items[$value[0]] . '.png');
imagecopyresampled($base,
$item,
floor(($value[1] / 100) * $baseWidth),
floor(($value[2] / 100) * $baseHeight),
0,
0,
$width,
$height,
$width,
$height);
imagedestroy($item);
}
//We have to capture the output buffer
ob_start();
imagepng($base);
$baseimg = ob_get_clean();
GD不支持32位PNG中的透明度。您必须将8位与一种透明的“颜色”或24位(官方24位不支持透明,但Photoshop在使用24位png的“保存为web”时可以做到这一点)。您可以提供原始文件的链接吗?可能是nope的副本,而不是副本。请看我使用不同合并函数的代码。@Casey:这是相同的基本问题。你所做的只是从品牌X工具切换到品牌Y。核心问题仍然是一样的。