{"id":535,"date":"2010-10-20T10:16:00","date_gmt":"2010-10-20T10:16:00","guid":{"rendered":""},"modified":"2010-10-20T10:16:00","modified_gmt":"2010-10-20T10:16:00","slug":"535","status":"publish","type":"post","link":"https:\/\/www.poloo.org\/?p=535","title":{"rendered":"PHP GD\u5e93\u4e2d\u6587\u4e71\u7801\u95ee\u9898\u89e3\u51b3"},"content":{"rendered":"<p>Google\u7684\u529e\u6cd5\uff1a <\/p>\n<p>\u5c06\u8981\u5904\u7406\u7684\u6c49\u5b57,\u5148\u7531UTF8\u7684\u6c49\u5b57\u8f6c\u6210html\u5b9e\u4f53\u5f62\u5f0f\u518d\u4f7f\u7528.<\/p>\n<p>\u793a\u4f8b\u4ee3\u7801:<br \/><code><br \/>&lt;?php<br \/>\/\/ini_set('JIS-mapped Japanese Font Support',false);<br \/>$pic=imagecreate(250,30);<br \/>$black=imagecolorallocate($pic,0,0,0);<br \/>$white=imagecolorallocate($pic,255,255,255);<br \/>$font=\"C:\/\/WINDOWS\/\/Fonts\/\/simhei.ttf\";<\/p>\n<p>$str = '\u4e2d\u534e\u4eba\u6c11\u5171\u548c\u56fd';<br \/>$str = mb_convert_encoding($str, \"html-entities\",\"utf-8\" );\/\/\u7ed3\u679c:&#21738;&#19968;&#38431;&#20248;&#20808;&#24320;&#29699;<\/p>\n<p>imagettftext($pic,10,0,10,20,$white,$font,$str);<\/p>\n<p>header(\"Content-type: image\/jpeg\");<br \/>$filename='.\/photo.jpg';<br \/>$im=imagecreatefromjpeg($filename);<br \/>imagecopymerge($im,$pic,0,0,0,0,250,30,50);<br \/>imagejpeg($im);<br \/>?&gt;<br \/><\/code><\/p>\n<p>pChart \u793a\u4f8b\u4ee3\u7801:<\/p>\n<p><code><br \/>&lt;?php<br \/>\/*<br \/>&nbsp;&nbsp;&nbsp;&nbsp; Example14: A smooth flat pie graph<br \/>*\/<\/p>\n<p>\/\/ Standard inclusions&nbsp;&nbsp; <br \/>header(\"content-type:text\/html; charset=utf-8\");<br \/>include_once(\"pChart\/pData.class.php\");<br \/>include_once(\"pChart\/pChart.class.php\");<br \/>\/\/ Dataset definition <br \/>$DataSet = new pData;<br \/>$DataSet-&gt;AddPoint(array(10,2,3,5,3),\"Serie1\");<br \/>$DataSet-&gt;AddPoint(iconv_arr(array(\"Jan\",\"\u4e8c\u6708\",\"\u4e09\u6708\",\"Apr\",\"May\")),\"Serie2\");<br \/>$DataSet-&gt;AddAllSeries();<br \/>$DataSet-&gt;SetAbsciseLabelSerie(\"Serie2\");<\/p>\n<p>\/\/ Initialise the graph<br \/>$Test = new pChart(300,200);<br \/>$Test-&gt;loadColorPalette(\"Sample\/softtones.txt\");<br \/>$Test-&gt;drawFilledRoundedRectangle(7,7,293,193,5,240,240,240);<br \/>$Test-&gt;drawRoundedRectangle(5,5,295,195,5,230,230,230);<\/p>\n<p>\/\/ Draw the pie chart<br \/>$Test-&gt;setFontProperties(\"Fonts\/simkai.ttf\",8);<br \/>$Test-&gt;drawBasicPieGraph($DataSet-&gt;GetData(),$DataSet-&gt;GetDataDescription(),120,100,70,PIE_PERCENTAGE,255,255,218);<br \/>$Test-&gt;drawPieLegend(230,15,$DataSet-&gt;GetData(),$DataSet-&gt;GetDataDescription(),250,250,250);<\/p>\n<p>$Test-&gt;Render(\"example14.png\");<\/p>\n<p>\/**<br \/>* \u5c06\u6587\u672c\u7531UTF8\u7f16\u7801\u8f6c\u5316\u4e3a\u6570\u5b57\u5f62\u5f0f\u7f16\u7801(HTML\u5b9e\u4f53)<br \/>* @param $arr \u8be5\u53c2\u6570\u53ef\u4ee5\u4e3a\u6570\u7ec4\u6216\u8005string<br \/>* @author Steven lxq70361@qq.com<br \/>*\/ <br \/>function iconv_arr($arr){ <br \/>if(is_array($arr)){<br \/>&nbsp;&nbsp; foreach($arr as $k=&gt;$v){<br \/>&nbsp;&nbsp;&nbsp;&nbsp;$arr[$k] = iconv_arr($v);<br \/>&nbsp;&nbsp; }<br \/>&nbsp;&nbsp; <br \/>}else{<br \/>&nbsp;&nbsp; $arr = mb_convert_encoding($arr, \"html-entities\",\"utf-8\" );<br \/>}<br \/>return $arr;<br \/>}<br \/>?&gt;<br \/><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google\u7684\u529e\u6cd5\uff1a \u5c06\u8981\u5904\u7406\u7684\u6c49\u5b57,\u5148\u7531UTF8\u7684\u6c49\u5b57\u8f6c\u6210html&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-535","post","type-post","status-publish","format-standard","hentry","category-Php"],"_links":{"self":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/535","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=535"}],"version-history":[{"count":0,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/535\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}