Chinaunix首页 | 论坛 | 博客
  • 博客访问: 17757892
  • 博文数量: 7460
  • 博客积分: 10434
  • 博客等级: 上将
  • 技术积分: 78178
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-02 22:54
文章分类

全部博文(7460)

文章存档

2011年(1)

2009年(669)

2008年(6790)

分类:

2008-04-17 17:34:05

 

你总是花很多时间去做一些按吧,去设计一个好的按背景全部用它吧!
  
文字可以随意更换!
  
    Header( "Content-type: image/gif");
  if(!isset($s)) $s=11;
  //times.tif
可以是你喜欢的任何字体
  $size = imagettfbbox($s,0, "/fonts/TIMES.TTF",$text);
  //
设定长宽
  $dx = abs($size[2]-$size[0]);
  $dy = abs($size[5]-$size[3]);
  $xpad=9;
  $ypad=9;
  $im = imagecreate($dx+$xpad,$dy+$ypad);
  //
设定R,G,B
  $blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);
  $black = ImageColorAllocate($im, 0,0,0);
  $white = ImageColorAllocate($im, 255,255,255);
  //
画图
  ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
  ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
  ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black, "/fonts/TIMES.TTF", $text);
  ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white, "/fonts/TIMES.TTF", $text);
  ImageGif($im);
  ImageDestroy($im);
  ?>
  
  
重要的是你不能在这段中加入任何的HTML标记,尤其不允许在and ?> 当中加入!
  
  
调用时写下面的代码:
  
  s
是图片的大小 text是图片的文字
  
赶快试一试吧! 

阅读(347) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~