gd.pl
#!/usr/bin/perl -w
use strict;
use GD;
my $image = GD::Image->newPalette(401,201);
my $gray = $image->colorAllocate(200,200,200);
my $red = $image->colorAllocate(255,0,0);
my $black = $image->colorAllocate(0,0,0);
#draw a field of polka dots with random diameters
foreach my $i (0..10) {
foreach my $j (0..5) {
my $d = rand(50)+1;
$image->arc($i*40, $j*40, $d, $d, 0, 360, $red);
$image->fill($i*40, $j*40, $red);
}
}
#draw the text in black
my ($x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4) = $image->stringFT($black, "/home/eugenep/arial.ttf", 48,0,40,120, "hello world");
#outline the text with a black box
$image->rectangle($x1-10, $y1+10, $x3+10, $y3-10, $black);
print $image->png;
它不显示任何东西,而是在命令提示符下显示一堆奇怪的字符。
有人告诉我可能是什么问题吗?