論壇目錄 / 程式設計 / 網頁/網站程式 / PHP /

使用 GD 函式產生透明的 GIF 圖像

發表新主題
隨機主題
上個主題
下個主題
|
    使用 GD 函式產生透明的 GIF 圖像

    ???

    首先要先確定您的 PHP 有支援 GD 函式庫。

    先用 imageCreate() 來建立一個GD圖像物件:

    產生透明的 GIF 圖像
    1. $Width=200;
    2. $Height=200;
    3. $GDPic = imageCreate($Width, $Height);
    4.  
    5. # 指定一個色來當作背景色(Red,Green,Blue):
    6. $BGColor = imageColorAllocate($GDPic, 255, 255, 255);
    7.  
    8. # 用背景色塗滿整個圖像:
    9. imageFilledRectangle($GDPic,0,0,$Width1,$Height,$BGColor);
    10.  
    11. # 字型檔所在位置:
    12. $UseFont = '../fonts/mingliu.ttc';
    13.  
    14. # 開始在圖上畫出想畫的東西比如寫一行字:
    15. $TextColor = imageColorAllocate($im, 50, 50, 255);
    16. imageTTFText($GDPic,5,0,50,90,$TextColor,$UseFont,"My Gif");
    17.  
    18. # 把背景色設定為透明色:
    19. imageColorTransparent($GDPic,$BGColor);
    20.  
    21. # 使用交錯模式:
    22. imageInterlace($GDPic);
    23.  
    24. #輸出成為 GIF:
    25. header("Content-type: image/gif");
    26. imageGif($GDPic);
    27.  
    28. 最後記得釋放圖像佔用的記憶體:
    29. imageDestroy($GDPic);

    • 關鍵字 : GDPic, Height, BGColor, imageCreate, Width, UseFont, TextColor, 首先要先確定您, 色來當作背景色, 用背景色塗滿整, 最後記得釋放圖, 把背景色設定為透明色, 如寫一行字, 圖上畫出想畫, 使用交錯模式, mingliu, imageTTFText, imageInterlace, imageGif, imageDestroy
    00
    2007-11-30T06:49:00+0000


    • 當您未登入羊皮紙時,可以利用臉書 Facebook 登入來發表迴響。若使用羊皮紙會員身份發表迴響則可獲得經驗值及虛擬金幣,用來參加羊皮紙推出的活動。
    發表迴響
     
    驗證字串
    留言