我有一个代码,可以根据输入值调整图像的大小和颜色...问题是,我只能使用其他应用程序保存的新图像着色一次。请帮助我..我希望有很多PHP expers在这里.....如何使用GD对PHP结果图像进行着色使用GD
<?php
createImage(50,50, 0,0, 255);
function createImage($width, $height, $nR, $nG, $nB)
{
$image = imagecreatefrompng("source.png");
imagealphablending($image, false);
imagesavealpha($image, true);
//resize the image
$new_image = imagecreatetruecolor($width, $height);
imagealphablending($new_image, false);
imagesavealpha($new_image, true);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $width, $height, imagesx($image), imagesx($image));
//colorize the image
$nrgb = str_pad(dechex($nR), 2, '0', STR_PAD_LEFT). str_pad(dechex($nG), 2, '0', STR_PAD_LEFT). str_pad(dechex($nB), 2, '0', STR_PAD_LEFT);
$newColor = $nrgb;
$c2 = sscanf($newColor ,"%2x%2x%2x");
for($i=0;$i<$width;$i++)
{
for($j=0;$j<$height;$j++)
{
$cIndex = imagecolorat($new_image,$i,$j);
imagecolorset($new_image,$cIndex,$c2[0],$c2[1],$c2[2]);
}
}
header("Content-Type: image/png");
imagepng($new_image,"test.png");
}
?>
您应该提供一些代码,并更好地解释问题。很难理解你想要问什么。 – nico 2011-03-08 17:21:25
请详细解释“colorize”是什么意思。理想情况下,一个“之前/之后”屏幕截图 – 2011-03-08 17:21:28
等待让我准备我的问题的短版本.....感谢您的快速响应... – Bagan 2011-03-08 17:22:56