Re: [GD-DEVEL] Problem with transparency

[email protected] ("Pierre Joye") Fri, 26 Sep 2008 17:56:31 +0200
Newsgroups php.gd.devel
Message-ID <[email protected]>
Hi Brian,

On Fri, Sep 26, 2008 at 5:09 PM, Brian Peschel <[email protected]> wrote:
> I am having a bit of a problem with transparency with GD.  Basically, I am
> creating an image and I want to insert a smaller image into the one I am
> creating.  It is working if I use a GIF image.  It is failing if I use a
> XPM, JPG, or PNG image.  I am sure I am missing something, but not sure what

>   gdImageCopy(_image, symbolImage, (int)round(from.x()), y, 0, 0,
> (int)round(imageWidth), (int)round(imageHeight));
>   gdImageDestroy(symbolImage);
>
> If I add in a debug line after loading the image of:
> std::cout << fileName << " Width " << imageWidth << " height " <<
> imageHeight << " transparent " << gdImageGetTransparent(symbolImage) <<
> std::endl;
>
> after loading the image I get these results:
> school.gif Width 20 height 10 transparent 3
> school.xpm Width 20 height 10 transparent -1
> school.jpg Width 20 height 10 transparent -1
> school.png Width 20 height 10 transparent -1

That means:

gif has a transparent color (background color), the color index is 3
All other has no transparent color (expected for JPEG, not sure if XPM
supports a background color). It could be the reason why the copy does
not work as you expect. However it would help if you show us the
source and destination images (per format), it will help to understand
exactly what you like to achieve (and what happens now with
xpm/jpeg/png).

Cheers,
-- 
Pierre

http://blog.thepimp.net | http://www.libgd.org