in reply to how can I set a real color while drawing text with GD
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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how can I set a real color while drawing text with GD
by gideondsouza (Pilgrim) on Aug 08, 2013 at 19:39 UTC |