|
/**
* 把图像按指定颜色扣成透明返回图像
* @param $image 源图像
* @param $r red
* @param $g green
* @param $b blue
* @param $w width
* @param $h height
* @return resource $timage 透明图像
*/
function transarent($image, $r, $g, $b, $w, $h){
$timage = imagecreatetruecolor($w,$h);
imagecopymerge($timage,$image,0,0,0,0,$w,$h,100);
for($x = 0; $x < $w; $x++) {
for($y = 0; $y < $h; $y++) {
if(imagecolorat($image, $x, $y)){
imagecolortransparent($timage,imagecolorallocate($timage, $r, $g, $b));
}
}
}
imagedestroy($image);
return $timage;
}
|
|
|