类型:转载 责任编辑:asp.net 日期:2007/05/23
热门软件下载:
1.imagecolorstotal() 的问题:
<body>
<?
$image="swallow.jpg";
$im = imagecreatefromjpeg($image);
echo $image.has .imagecolorstotal($im). colors in its palette;
imagedestroy($im);
?>
</body>
结果总是swallow.jpghas 0 colors in its palette;
为什么会是0呢??
2.imagecolorat()的问题:
<body>
<?
$image="swallow.jpg";
$im = imagecreatefromjpeg($image);
$cindex = imagecolorat($im,0,0);
$rgb_color=imagecolorsforindex($im,$cindex);
echo $rgb_color[red];
echo $rgb_color[green];
echo $rgb_color[blue];
?>
</body>
执行到“$cindex = imagecolorat($im,0,0);”时,
总是弹出内存不能为读得提示。
请各位高手不吝赐教。先谢过!
网友回答:
Actually that is not true.
When you use for example imagecreatefromjpeg() you create a truecolor image resource (as with the other truecolor image types). If you try to get the number of colors using imagecolorstotal() you get 0 (thats what happened to me at least). Instead you must convert the trucolor resource to pallete resource. You have to do that like this:
<?
$simg=createfromjpeg("somejpeg.jpg");
imagetruecolortopalette($simg, false, 256);
$colors=imagecolorstotal($simg);
?>
帮你顶,接分
关注!
帮你顶一下,顺便接点分~~