<?php
/*此案例圖片文件損壞*/
ob_clean();//清除緩存
//創(chuàng)建畫布???畫布默認(rèn)是黑色的
$image?=?imagecreatetruecolor(500,500);
//創(chuàng)建顏色
$white?=?imagecolorallocate($image,?255,?255,?255);
echo?"121";
$randColor?=?imagecolorallocate($image,?mt_rand(0,?255),?mt_rand(0,?255),?mt_rand(0,?255));//隨機(jī)顏色
//繪制圖像
//畫一個矩形并填充???參數(shù)?:??資源??x??y?width?height?color
imagefilledrectangle($image,0,0,500,500,$white);
//字體???參數(shù):資源??角度??x?y?color?字體路徑??content
//$button_text=iconv("gbk","UTF-8",$button_text);
//header('content-type:image/jpeg;charset=utf-8');
imagettftext($image,?20,?0,?100,?100,?$randColor,?'arial.ttf',?'this?is?image');
imagepng($image);//顯示圖片
//imagejpeg($image,'img/1.png');//保存圖片
//銷毀資源
imagedestroy($image);
?>imagettftext()這個函數(shù)怎么用呀,調(diào)的時候不知道怎么弄得成功了一次,之后就調(diào)不回來了,換了好多種字體都沒用,運(yùn)行又不報錯,在網(wǎng)上看到要注釋掉header的說明,就可以看到錯誤,但是注釋掉之后只看到隨機(jī)的亂碼。如果將這個方法注釋掉,卻會看到背景。怎樣才是這個方法的正確打開方式呢?
- 2 回答
- 0 關(guān)注
- 2439 瀏覽
添加回答
舉報
0/150
提交
取消