//PNG格式图像处理函数
function Loadpng ($imgname) {
$im = @ImageCreateFromPNG ($imgname);
if (!$im) { //载入图像失败
$im = ImageCreate (400, 30);
$bgc = ImageColorAllocate ($im, 255, 255, 255);
$tc = ImageColorAllocate ($im, 0, 0, 0);
ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc);
ImageString($im, 4, 5, 5, "Error loading: $imgname", $tc);
}
return $im;
}
$imgPng=Loadpng("./karte.png");
/* 输出图像到浏览器 */
header("Content-type: image/png");
imagePng($imgPng);
?>
|