羊皮纸论坛目录 / 程式设计 / 网页/网站程式 / 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
0 0
2007-11-30T06:49:00+0000


  • 当您未登入羊皮纸时,可以利用脸书 Facebook 登入来发表回响。若使用羊皮纸会员身份发表回响则可获得经验值及虚拟金币,用来参加羊皮纸推出的活动。
发表回响
 
验证字串