您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP实现在图片中添加中文文字

2024/12/7 11:58:52发布23次查看
text=!isset($showtext)?$showtext:$this->text;
  //exit();
  $this->show();
 }
 function createtext($instring)
 {
   $outstring=;
   $max=strlen($instring);
   for($i=0;$i   {
   $h=ord($instring[$i]);
   if($h>=160 && $i   {
              $outstring.=.base_convert(bin2hex(iconv(gb2312,ucs-2,substr    ($instring,$i,2))),16,10).;;
              $i++;
   }
   else
   {
              $outstring.=$instring[$i];
   }
   }
  return $outstring;
 }
 function createjpeg()
 {}
 function show()
 {
  //输出头内容
  header( content-type: image/png);
  //建立图象
  $image = imagecreate(400,300);
  //定义颜色
  $red = imagecolorallocate($image,255,0,0);
  $white = imagecolorallocate($image,255,255,255);
  $black=imagecolorallocate($image,0,0,0);
  //填充颜色
  imagefilledrectangle($image,0,0,200,200,$red);
  //显示文字
  $txt=$this->createtext($this->text);
  //写入文字
  imagettftext($image,$this->size, $this->angle, $this->showx, $this->showy,$white,$this->font,$txt);
  //imagestring($image,5,50,10,$txt,$white);
  //显示图形
  imagejpeg($image);
  imagedestroy($image);
 }
}
//本类,并没有经过很好的考虑,只是简单的进行了封装,以后有机会,可能跟原来的图片类整合
?>
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product