用ImageTTFText在图片上显示汉字的问题。 感觉可能是后部分((round(10000*($datLst[$i]/$tot))/100))由些问题!!有时可以、有时不可以,这个问题比较怪,你试一下换个字体文件试一下。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 换了simkai.ttf字体,也是相同现象。偶尔可以显示,大部分时间不能显示。 楼上的,已经用$str = iconv("GB2312", "UTF-8", $labLst[$i]);做了转换啊function draw_img($datLst,$labLst,$clrLst,$a=250,$b=120,$v=20,$font=10){ $ox = 5+$a; $oy = 35+$b; $fw = imagefontwidth($font); $fh = imagefontheight($font); $n = count($datLst);//数据项个数 $w = 10+$a*2;// $h = 10+$b*2+$v+($fh+2)*$n; $h = 10+$b+$v+($fh+2)*$n;// $h = 10+$v+($fh+2)*$n; $img = imagecreate($w, $h);//转RGB为索引色 for($i=0; $i<$n; $i++) $clrLst[$i] = draw_getindexcolor($img,$clrLst[$i]); $clrbk = imagecolorallocate($img, 0xff, 0xff, 0xff); $clrt = imagecolorallocate($img, 0x00, 0x00, 0x00);//填充背景色 imagefill($img, 0, 0, $clrbk);//求和 $tot = 0; for($i=0; $i<$n; $i++) $tot += $datLst[$i]; $sd = 0; $ed = 0; $ly = 10+$b*2+$v; for($i=0; $i<$n; $i++) { $sd = $ed; $ed += $datLst[$i]/$tot*360;//画圆饼 draw_sector3d($img, $ox-150, $oy-50, $a, $b, $v, $sd, $ed, $clrLst[$i]); //$sd,$ed,$clrLst[$i]);//可控制位置//画标签 imagefilledrectangle($img, 235, $ly-250, 240+$fw, $ly+$fh-250, $clrLst[$i]);//可控制x、y位置 imagerectangle($img, 235, $ly-250, 240+$fw, $ly+$fh-250, $clrt);//可控制x、y位置// imagestring($img, $font, 5+2*$fw, $ly, $labLst[$i].":".$datLst[$i]."(".(round(10000*($datLst[$i]/$tot))/100)."%)", $clrt); $str = iconv("GB2312", "UTF-8", $labLst[$i]);//可控制x、y位置,控制显示字体 ImageTTFText($img, $font, 0, 245+2*$fw, $ly+13-250, $clrt, "f:/website/htdocs/tmp/font/simhei.ttf", $str.":".$datLst[$i]."(".(round(10000*($datLst[$i]/$tot))/100)."%)"); $ly += $fh+2; }//输出图形 header("Content-type: image/png");//输出生成的图片// $imgFileName = "../temp/".time().".png";// imagepng($img,$imgFileName); imagepng($img);//释放资源 imagedestroy($img);} 今天rp太差,配置phpnow总是出错。请教下大家 简单的php字符串匹配问题 如何实现PHP与应用程序间的通信? 浏览器后退按钮,回到上上个网页 怎样做出以下的日期显示格式 请高手帮帮忙! 请问,如何实现关闭页面的同时自动删除session? 强人进!!我用mail()发邮件,请问,发送对象有数量有限制吗? 怎样用PHP发邮件?(windows2000 server) <a href="XXX.php?">问号后面的参数是怎么传的? php二维数组合并问题 php可以使用acc的数据库吗?
{
$ox = 5+$a;
$oy = 35+$b;
$fw = imagefontwidth($font);
$fh = imagefontheight($font);
$n = count($datLst);//数据项个数
$w = 10+$a*2;
// $h = 10+$b*2+$v+($fh+2)*$n;
$h = 10+$b+$v+($fh+2)*$n;
// $h = 10+$v+($fh+2)*$n;
$img = imagecreate($w, $h);//转RGB为索引色
for($i=0; $i<$n; $i++)
$clrLst[$i] = draw_getindexcolor($img,$clrLst[$i]);
$clrbk = imagecolorallocate($img, 0xff, 0xff, 0xff);
$clrt = imagecolorallocate($img, 0x00, 0x00, 0x00);//填充背景色
imagefill($img, 0, 0, $clrbk);
//求和
$tot = 0;
for($i=0; $i<$n; $i++)
$tot += $datLst[$i]; $sd = 0;
$ed = 0;
$ly = 10+$b*2+$v; for($i=0; $i<$n; $i++)
{
$sd = $ed;
$ed += $datLst[$i]/$tot*360;
//画圆饼
draw_sector3d($img, $ox-150, $oy-50, $a, $b, $v, $sd, $ed, $clrLst[$i]); //$sd,$ed,$clrLst[$i]);//可控制位置
//画标签
imagefilledrectangle($img, 235, $ly-250, 240+$fw, $ly+$fh-250, $clrLst[$i]);//可控制x、y位置
imagerectangle($img, 235, $ly-250, 240+$fw, $ly+$fh-250, $clrt);//可控制x、y位置
// imagestring($img, $font, 5+2*$fw, $ly, $labLst[$i].":".$datLst[$i]."(".(round(10000*($datLst[$i]/$tot))/100)."%)", $clrt);
$str = iconv("GB2312", "UTF-8", $labLst[$i]);
//可控制x、y位置,控制显示字体
ImageTTFText($img, $font, 0, 245+2*$fw, $ly+13-250, $clrt, "f:/website/htdocs/tmp/font/simhei.ttf", $str.":".$datLst[$i]."(".(round(10000*($datLst[$i]/$tot))/100)."%)");
$ly += $fh+2;
}//输出图形
header("Content-type: image/png");
//输出生成的图片
// $imgFileName = "../temp/".time().".png";
// imagepng($img,$imgFileName);
imagepng($img);
//释放资源
imagedestroy($img);
}