So by default GD only supports 256 colors. The image you are using must not have any pixel set to (0,0,0) so there is no way to match it exactly or to allocate it for that matter. What you could do is:
my $black = $im->colorClosest(0,0,0);
Which will work and get you something very close to (0,0,0) and likely be indistinguishable visually. However if you set truecolor right after importing GD, you can avoid all these issues and your colorAllocate above will work. However i'd suggest using colorResolve instead, which will use an existing index or create a new one automatically if needed:
HTH.use GD; GD::Image->trueColor(1); ... my $black = $im->colorResolve(0,0,0);
In reply to Re: how can I set a real color while drawing text with GD
by Loops
in thread how can I set a real color while drawing text with GD
by gideondsouza
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |