+ -
当前位置:首页 → 问答吧 → 请问GD画图在网页中输出的问题

请问GD画图在网页中输出的问题

时间:2010-09-24

来源:互联网

我在数据库取出几行数据来画图,
取数据和画图不能在同一个程序进行么
比如我用这段GD代码
  1.     use GD;

  2.     #print "Content-type:text/html\n\n";
  3.     print "Content-type: image/png\n\n";

  4.         my $im = new GD::Image(900,100);

  5.         # allocate some colors
  6.         my $white = $im->colorAllocate(255,255,255);
  7.         my $black = $im->colorAllocate(0,0,0);      
  8.         my $red = $im->colorAllocate(255,0,0);      
  9.         my $blue = $im->colorAllocate(0,0,255);
  10.                
  11.         # make the background transparent and interlaced
  12.         $im->transparent($white);
  13.         $im->interlaced('true');

  14.      # Put a black frame around the picture
  15.        $im->rectangle(100,0,100,20,$black);
  16.        $im->fill(100,10,$black);

  17.        $im->line(100,10,100,10,$black);
  18.        
  19.        $im->string(gdLargeFont,0,5,'fsfsd',$black);
  20.        $im->string(gdLargeFont,0,40,'fdsafds',$black);
  21.        
  22.        # make sure we are writing to a binary stream
  23.         binmode STDOUT;

  24.         # Convert the image to PNG and print it on standard output
  25.         print $im->png;
复制代码
我有几个问题:
1. print "Content-type: image/png\n\n";  加了这个头之后是不是不能再加其它的头,就是这个页面要么用来输出图片,要么用来输出文字

2. 我想把图片放在某个表格之中,是不是只能把数据传递到另外一个页面进行计算

3. 因为我的数据有多行,但是我不知道具体有多少行,所以只能用循环来取数据,那么,如果我想把这多行画在一张图片上(因为我想把它们对齐),或者说输出到同一个表格里,应该怎么办呢,我用循环的话是不是每次只能传递一行数据,那如何把多行数据都画出来呢

请求大侠指导,非常感谢!

作者: duziteng   发布时间: 2010-09-24

  1. #!/usr/bin/perl
  2. print "Content-type: text/html\n\n";
  3. print <<EOF;
  4. <html>
  5. <head>
  6. <title>picture test</title>
  7. </head>
  8. <p><img border="0" src="/cgi-bin/gd_test.pl"></p>
  9. <body>
  10. </body>
  11. </html>
  12. EOF
复制代码
可以在HTML中调用GD程序

作者: iamlimeng   发布时间: 2010-09-24