资讯   |   开发   |   选机中心   |   产品大全 | IBM | 惠普 | 联想 | 戴尔 | 苹果 | 神舟
更多: | 华硕 | 明基 | 方正 | 紫光 | TCL | 夏新 | 联宝 | 宏碁 | 七喜 | 长城 | 清华同方 | 海尔 | 三星 | 东芝 | 索尼 | 富士通 | LG | 技术 | ddnoon
当前位置:笔记本 > 软件开发 >
Advertisement
文章正文

imagecolorstotal() 和 imagecolorat()的使用问题,散分。

类型:转载   责任编辑: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);”时,  
  总是弹出内存不能为读得提示。  
   
  请各位高手不吝赐教。先谢过!

网友回答:

发表者:ice_berg16

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);  
  ?>

发表者:tpf9000

帮你顶,接分

发表者:mary0226

关注!

发表者:bimyboy

帮你顶一下,顺便接点分~~


 

 
热门推荐笔记本: 腾龙笔记本
相关文章:
webmaster:popbb@126.com   最佳浏览:1024X768 MSIE
©2007 popbb.net All Rights Reserved