Page 1 of 1

GD transparent index shifting

Posted: Sun Feb 19, 2006 1:06 pm
by yum-jelly
I am working on adding ellipse cropping tool for my SGML capture system, but I am having some trouble with the transparent index color shifting position in the palette. When I first set the transparent color it always is in index 1, but after calling imagecopy() to layer the ellipse cropping area it get shifted in the palette. I figured allocating (1) color would make it shift to index (2), but it gets shifted to a random index and then set the transparent color to the orignal transparent color but to some index that is not in the palette anymore. Confused, so am I!

Say you have a image with 200 colors in a palette of 256 colors. The 200 colors are the only colors used. So before layering the transparent index is at index (1), after layering index (1) still holds the transparent color, but the transparent index has moved to index (222), which is not in the range of the active color palette.

So does anyone know how one can multi layer images, while not shifting the transparent index everytime you allocate a new color? I can do this fine with ImageMagick, but I am trying to keep development to just PHP, so users will not have to install other things just to support different shaping tools!

Here is example of the cropping tool so you can see what I trying to do...

http://www.ya-right.com/tools.php?t=0&s ... 632cfe5524

TIA

yj!

Posted: Sun Feb 19, 2006 3:26 pm
by John Cartwright
Moved to PHP-GD.

Posted: Sun Feb 19, 2006 5:34 pm
by onion2k
As far as I know there's no way to control the exact palette position of any particular color unless you rewrite the palette by hand or copy it from another image.

Posted: Wed Mar 15, 2006 9:39 am
by Pierre.gd
Can you provide a small script to reproduce what you want to do? The elliptical selection does not really matter. Also be sure to use the bundled gd as Jcart noticed.