This post goes on a bit but I'd be very grateful for any help.

I'm trying to re-colour an image in PHP (a png file, therefore paletted) but I can't add new colours to the palette. Why? Because to do so you have to use imagecolorallocate. That's fine, except when I come to use imagecolorset you need the specific RGB values to enter, so the value assigned with imagecolorallocate is useless.

If you simply try to do:

imagecolorset($im, 255, 0, 0); ...

in a paletted image, it obviously just comes out as a colour already in the palette. So could someone tell me:

1) Is there a simple way of returning specific R, G or B values from a variable set with imagecolorallocate?

2) Is it really impossible to flip from palette mode to truecolour? You can do it the other way round.

3) Is there no way to replace colour simply using a colour stored in a var using imagecolorallocate, e.g...

imagecolorset($image, $my_colour);

Rather than... imagecolorallocate($im, R, G, B);

Thanks in advance.