Andrew Gaffney <[EMAIL PROTECTED]> wrote:
: 
: I wrote my own script based off your example and the docs
: at <http://search.cpan.org/~lds/GD-2.11/GD.pm>. When I
: run the below program, I get:
: 
: 
: skyline skyline-src # ./genbutton.pl
: gd-png:  fatal libpng error: Invalid number of colors in palette
: gd-png error: setjmp returns error condition

    You haven't set the palette. You need to Allocate()
colors into the palette before you can choose the
Closest() color in the palette. I changed $blue to
$green. It was easier to see the text that way.

 
my $im = new GD::Image->new(51, 20);

my $gray    = $im->colorAllocate( 127, 127, 127 );
my $green   = $im->colorAllocate(   0, 190, 200 );
my $white   = $im->colorAllocate( 255, 255, 255 );
my $black   = $im->colorAllocate(   0,   0,   0 );

$im->transparent($white);

$im->filledRectangle( 0, 0, 51, 20, $white );

$im->filledRectangle( 4, 4, 51, 20, $gray  );
$im->filledRectangle( 0, 0, 47, 16, $green );

$im->string( gdSmallFont, 3, 3, "Test", $black );

my $png = 'testbutton.png';
open PNG, ">/home/httpd/htdocs/$png" or die qq|Can't write "$png": $!|;
    binmode PNG;
    print PNG $im->png;
close PNG;


HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to