課程
/后端開發(fā)
/PHP
/PHP進(jìn)階篇-GD庫(kù)圖像處理
老師怎么我把你寫的代碼放在我的電腦上打開是黑屏呢
2017-07-06
源自:PHP進(jìn)階篇-GD庫(kù)圖像處理 2-3
正在回答
沒有繪制矩形填充
Imagefilledrectangle( $image, 坐標(biāo)x, 坐標(biāo)y, 畫布寬, 畫布高, $white );
出現(xiàn)黑色的主要原因 應(yīng)該還是imagefilledreatangle()這里的問(wèn)題
除了gd庫(kù),還要打開extension那個(gè),第一節(jié)
自己琢磨
<?php/** * Created by PhpStorm. * User: qy-010 * Date: 2017/9/7 * Time: 22:37 *///創(chuàng)建畫布header('content-type:text/html;charset=utf-8');$width=500;$height=300;$image=imagecreatetruecolor($width,$height);//創(chuàng)建顏色//imagecolorallocate();$red=imagecolorallocate($image,255,0,0);$blue=imagecolorallocate($image,0,0,255);$white=imagecolorallocate($image,255,255,255);//開始繪畫//imagechar水平地書寫一個(gè)字符imagechar($image,5,50,100,'K',$red);//垂直一個(gè)字符imagecharup($image,5,100,200,'i',$blue);//水平一行字符串imagestring($image,5,200,150,'ksm best',$white);ob_clean();//輸出或者保存圖像//告訴瀏覽器以圖片的形式來(lái)顯示header('content-type: image/jpeg;charset=utf-8');imagejpeg($image);//輸出圖像imagegif()imagepng()//銷毀程序imagedestroy($image);
是因?yàn)閳D片顯示失敗了吧,逐行刪減代碼,看看是哪里出了問(wèn)題…
舉報(bào)
想通過(guò)PHP中GD函數(shù)庫(kù)靈活操作圖像嗎,點(diǎn)擊學(xué)習(xí)本教程可以實(shí)現(xiàn)
1 回答老師 我按照你屏幕上的1.php敲的 瘋狂報(bào)錯(cuò)是咋回事。。
3 回答老師你支持中文的這個(gè)font在哪里的,我也是mac沒有找到
5 回答我跟著老師寫輸出到瀏覽器是亂碼
1 回答老師,你給我埋了坑啊
2 回答界面是黑色背景
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2018-10-28
沒有繪制矩形填充
Imagefilledrectangle( $image, 坐標(biāo)x, 坐標(biāo)y, 畫布寬, 畫布高, $white );
2018-05-28
出現(xiàn)黑色的主要原因 應(yīng)該還是imagefilledreatangle()這里的問(wèn)題
2017-11-20
除了gd庫(kù),還要打開extension那個(gè),第一節(jié)
2017-09-13
自己琢磨
<?php
/**
* Created by PhpStorm.
* User: qy-010
* Date: 2017/9/7
* Time: 22:37
*/
//創(chuàng)建畫布
header('content-type:text/html;charset=utf-8');
$width=500;
$height=300;
$image=imagecreatetruecolor($width,$height);
//創(chuàng)建顏色
//imagecolorallocate();
$red=imagecolorallocate($image,255,0,0);
$blue=imagecolorallocate($image,0,0,255);
$white=imagecolorallocate($image,255,255,255);
//開始繪畫
//imagechar水平地書寫一個(gè)字符
imagechar($image,5,50,100,'K',$red);
//垂直一個(gè)字符
imagecharup($image,5,100,200,'i',$blue);
//水平一行字符串
imagestring($image,5,200,150,'ksm best',$white);
ob_clean();
//輸出或者保存圖像
//告訴瀏覽器以圖片的形式來(lái)顯示
header('content-type: image/jpeg;charset=utf-8');
imagejpeg($image);//輸出圖像imagegif()imagepng()
//銷毀程序
imagedestroy($image);
2017-07-08
是因?yàn)閳D片顯示失敗了吧,逐行刪減代碼,看看是哪里出了問(wèn)題…