Forum

Yampiz Forum

Sharing let knowledge Spreaded, Reading let spirits growth, Creative let culture extended, Let us
  • 禁止廣告文
  • 知識傳播
  • 閱讀
  • 心靈成長
  • 創作
  • 文化傳承
Forum 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
0 0
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

Facebook Page

QR-Code and APP Launcher

User Guide
This Webpage

In those service tabs, "Scan QRCode, in mobile device" or "Click the button, in this device" to open webpage or APP-related operations.
QRCode
  • Auto Platform
    For better browsing experience, it will auto detects your device to display webpage.
  • Bug Report
    Tell us about the idea, problem and errors you found.
  • Comodo Secure
    The sensitive data transmission adopts by SSL-2048 authenticated encryption.
  • Copyright
    © 2009 YamPiz Digital Inc. & Jaby Group. All rights reserved.
  • Revised Version
    V2.2.197
    29 Oct 2024 (GMT+8)