【发布时间】:2011-07-01 23:42:55
【问题描述】:
合并两个具有透明部分的图像会生成以下合成图像:
我想知道为什么我覆盖在绿色背景上的图像的透明部分会这样显示?有人吗?
$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();
【问题讨论】:
-
你能提供原始文件的链接吗?
-
不,不是重复的。看看我使用不同合并函数的代码。
-
@Casey:这是同一个基本问题。您所做的只是从品牌 X 工具切换到使用品牌 Y。核心问题保持不变。
标签: php png gd alphablending