这个简单,用GD的函数。我想问一下,如何实现中文PNG图片呢?

解决方案 »

  1.   

    <?php
    Header("Content-type: image/PNG"); $myip="127.0.0.1";$im = imagecreate(100,20); 
    $bkg = ImageColorAllocate($im, 220,220,220); for ($i = 0; $i < strlen($myip); $i++) {
    imagestring($im, 5, $i*10+10, 0, substr($myip,$i,1), ImageColorAllocate($im,rand(5, 255),rand(5, 255),rand(5, 255)));
    }ImagePNG($im); 
    ImageDestroy($im); ?>
      

  2.   

    <?php
    Header("Content-type: image/PNG"); $im = imagecreate(400,50); 
    $bkg = ImageColorAllocate($im, 128,64,225); 
    $clr = ImageColorAllocate($im, 255,255,255); $fnt = "c:\winnt\fonts\simsun.ttc";//linux下改成linux下的字库路径
    $str = iconv("GB2312","UTF-8","欢迎光临"); 
    ImageTTFText($im, 20, 0, 230,40, $clr, $fnt, $str); $black = ImageColorAllocate($im, 0,0,0);
    $white = ImageColorAllocate($im, 255,255,255);
    imageline($im, 1, 1, 350, 25, $black);
    imagearc($im, 200, 15, 20, 20, 35, 190, $white);
    imagestring($im, 5, 4, 10, "Graph TEST!!", $white);ImagePNG($im); 
    ImageDestroy($im); ?>
      

  3.   

    to唯她
    能讲讲这一部分的意思吗?
    for ($i = 0; $i < strlen($myip); $i++) {
    imagestring($im, 5, $i*10+10, 0, substr($myip,$i,1), ImageColorAllocate($im,rand(5, 255),rand(5, 255),rand(5, 255)));
    }
      

  4.   

    还有就是如何让文本按一定的格式生成图片?
    比如我想生成这样的图形,应如何实现?解出来再加50。 127.0.0.1
    -------------
    Made in China
      

  5.   

    for ($i = 0; $i < strlen($myip); $i++) {
    imagestring($im, 5, $i*10+10, 0, substr($myip,$i,1), ImageColorAllocate($im,rand(5, 255),rand(5, 255),rand(5, 255)));
    }
    :将字串"127.0.0.1"一个字个字的分别以不同的随机色画出.
    imagestring(资源变量,大小,左距,顶距,字符串变量,颜色值).
    rand(5, 255)产生5-255之间的数值.
      

  6.   

    <?php
    Header("Content-type: image/PNG"); $myip="127.0.0.1";$im = imagecreate(100,35); 
    $bkg = imagecolorallocatealpha($im, 220,220,220,0.6 ); //背景色
    $red = imagecolorallocatealpha($im, 220,0,0,0.6 ); //红色
    $blue = imagecolorallocate($im, 0,0,220 ); //蓝色
    for ($i = 0; $i < strlen($myip); $i++) {
    imagestring($im, 5, $i*10+5, 0, substr($myip,$i,1), $blue);//ImageColorAllocate($im,rand(5, 255),rand(5, 255),rand(5, 255))改成这样就成了随机色
    }
    imagestring($im,5,5,10,"----------",$red);
    imagestring($im,3,5,20,"Made in China",$red);ImagePNG($im); 
    ImageDestroy($im); ?>
      

  7.   

    to 惟她$str  =  iconv(  "GB2312  ",  "UTF-8  ",  "欢迎光临  ");    这个程序提示未定义的函数,不知什么问题,先结账吧,能不能把这个解决后的发到我的留言