Re: [GD-DEVEL] re: Blending images with alpha (patches inside)
[email protected] (Pierre)
| Newsgroups | php.gd.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Patrick, Ethan, On 8/20/07, Ethan A Merritt <[email protected]> wrote: > On Sunday 19 August 2007 20:34, patrick keshishian wrote: > > > > What I was trying to accomplish with my patch was to provide for > > a method by which the user/programmer could change the level of > > opacity of a source image at run-time. > > If I understood correctly, your watermark image is transparent > everywhere except for the watermark itself. In this case can you > not use the function > gdImageCopyMerge(..., pct) > where pct is the multiplier for the alpha channel value of the > watermark itself? gdImageCopyMerge and gdImageCopyMergeGray have been implemented to emulate a global alpha channel and ignore the alpha channel in the source image. Sadly the documentation did not mention it clearly and only the comments in the source codes mention this restriction. If we can consider the addition of the alpha support as a bug fix, it will be easy to fix this problem. But I think it is a backward compatibility break. We can add the function proposed by Patrick. To be complete, I would prefer to name it gdImageCopyBlend (as it copies the src over the dst image and does not create a new image) and change its API to: gdImageCopyBlend(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int opacity, int mode) or drop the mode argument and add: gdSetBlendMode(gdImagePtr im, int mode); gdGetBlendMode(gdImagePtr im, int mode); where mode is the blending mode (overaly, add, sub, etc.). Other suggestions, comments or ideas are welcome :) Cheers, --Pierre