I took the liberty of removing the DBI stuff to make your GD example work.
I'm using ActiveState on Win9x. I had to remove the "\n\n" from Content-type
as well as changing the Content-type to image/jpeg.

#!\perl\bin\perl.exe -w
print <<HTML_SCRIPT1;
Content-type: image/jpeg

HTML_SCRIPT1
use CGI;
use GD;
my $q = new CGI;
my $lobtype = $q->param( "Lob" );
my @rawsql = "*";
binmode STDOUT;
testgraph();

sub testgraph{
my $image = new GD::Image( 100, 100);
my $background = $image->colorAllocate( 255, 255, 255);
my $area_color = $image->colorAllocate( 255, 0, 0);
my $axis_color = $image->colorAllocate( 0, 255, 0);
my $text_color = $image->colorAllocate( 0, 0, 255);
$image->string(gdLargeFont, 10, 15, "Third Year Output", $text_color );
my $polygon = new GD::Polygon;
$polygon->addPt( 30, 50);
for (my $i =0; $i < 100; $i++){
        $polygon->addPt(30 + 100 /(100 -1 ) * $i, 50 - $i * 100 / 10 );}
$polygon->addPt(30 + 100, 50);
$image->filledPolygon($polygon, $area_color); 
$image->line(30, 50, 30 +100, 50, $axis_color);
$image->line(30, 50, 30, 50 -100, $axis_color);
$image->transparent($background);
print $image->jpeg;
} 

> -----Original Message-----
> From: Grierson, Garry (UK07) [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, June 22, 2001 1:44 AM
> To:   '[EMAIL PROTECTED]'
> Subject:      GD Problem.
> 
> Iv just started my very first attempt at using GD to produce graphics and
> I'm confused. I have RTFM in fact iv read a few but I'm still confused.
> 
> I'm using ActivePerl on an NT system, so I loaded in the GD module using
> PPM, set the binmode to STDOUT as specified in the manual and wrote a hunk
> of code that I think should produce a big rectangle (it's only a test!). I
> tried outputting in both PNG and JPEG format but it just appears as
> 'hieroglyphics' on the browser page, obviously this is being interpreted
> as
> text instead of graphical information.
> I'm sure I'm being stupid and missed something fundamental. Help please!
...

Reply via email to