0
我已經盡了一切努力來解決這個問題。我花了一個多小時研究和嘗試代碼,但沒有任何幫助。背景是黑色
此代碼執行以下操作。
- 採取兩種完全黑白圖像,並重新將它們上色(,同時保持透明度)
- 合併兩個圖像融合在一起
- 輸出圖像(但與黑色背景!)
有人可以幫助識別和修補導致黑色背景的部分嗎?有關腳本的示例,請參閱以下URL。
-
$final_image = imagecreatetruecolor($dimensions, $dimensions); imagesavealpha($final_image, true); if($bgShape != '') { list($originalWidth, $originalHeight) = getimagesize('../images/' . $bgShape); $background = imagecreatefrompng('../images/' . $bgShape); imagefilter($background, IMG_FILTER_BRIGHTNESS, -255); imagefilter($background, IMG_FILTER_COLORIZE, $bgColorR, $bgColorG, $bgColorB); $backgroundImage = imagecreatetruecolor($dimensions, $dimensions); imagealphablending($backgroundImage , false); imagesavealpha($backgroundImage , true); imagecopyresampled($backgroundImage, $background, 0, 0, 0, 0, $dimensions, $dimensions, $originalWidth, $originalHeight ); imagecopy($final_image, $backgroundImage, 0, 0, 0, 0, $dimensions, $dimensions); /// $icon = imagecreatefrompng("../" . $icon); imagefilter($icon, IMG_FILTER_BRIGHTNESS, -255); imagefilter($icon, IMG_FILTER_COLORIZE, $iconColorR, $iconColorG, $iconColorB); $iconImage = imagecreatetruecolor($dimensions, $dimensions); imagealphablending($iconImage , false); imagesavealpha($iconImage , true); imagecopyresampled($iconImage, $icon, 0, 0, 0, 0, $dimensions, $dimensions, $originalWidth, $originalHeight ); imagecopy($final_image, $iconImage, 0, 0, 0, 0, $dimensions, $dimensions); /// imagealphablending($final_image, true); imagesavealpha($final_image, true); imagepng($final_image, NULL, 0, PNG_NO_FILTER); header("Content-type: image/png"); imagedestroy($backgroundImage);