Dictionary / Programming / 網頁/網站程式 / PHP /

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

New Subject
Random
Previous
Next
|
    使用 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);

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


    • Now, you can post comments by Facebook Account when your Yampiz account was logout or unvariable. whatever, we suggest to post comment by Yampiz Account to get more bounds to join new events of Heyxu
    Comment
     
    Verify
    Comment