Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

HI All, I am using GD.pm to create some image. How do I change the background of the image to white when using truecolor. By default, truecolor images are always filled with black at creation time. Thanks NC

Replies are listed 'Best First'.
Re: Problem with Truecolor image
by zentara (Cardinal) on Aug 18, 2005 at 14:04 UTC
    I'm guessing that you are the same person who asked this question in comp.lang.perl.misc, so I will use the example from there.
    #!/usr/bin/perl use GD; GD::Image->trueColor(1); $im = new GD::Image( 1000, 20 ); $white = $im->colorAllocate(255,255,255); $im->fill(20,1000,$white); $ctr = 0; $x = 0; $y = 10; while ( $ctr < 500 ) { $randomRed = int( rand(256) ) + 0; $randomGreen = int( rand(256) ) + 0; $randomBlue = int( rand(256) ) + 0; $getColor = $im->colorAllocate( $randomRed, $randomGreen, $randomBl +ue ); $im->line( $x, $y + 5, $x, $y - 5, $getColor ); $x++; $ctr++; } print $im->png;

    I'm not really a human, but I play one on earth. flash japh
      Thanks for the help. Your suggestion helped in what I want. Cheers Nagesh