Re: [GD-DEVEL] Drawing anti-aliased text with transparent background
| From: | Pierre | Date: | Sun, 18 Mar 2007 12:03:38 +0000 |
| Subject: | Re: [GD-DEVEL] Drawing anti-aliased text with transparent background | ||
| References: | 1 2 3 4 | Groups: | php.gd.devel |
| Request: | Send a blank email to php-gd-devel+get-141@lists.php.net to get a copy of this message | ||
HI Ethan,
On 3/18/07, Ethan A Merritt <merritt@u.washington.edu> wrote:
On Saturday 17 March 2007 11:54, Pierre wrote: On 3/17/07, Andrei Stebakov <lispercat@gmail.com> wrote:Please note that in my example it is a not the transparent color has a maximum alpha (gdAlphaTransparent).My goal is to create a .png image that has some text on a transparent background.Here you go: and the code: http://cvs.php.net/viewvc.cgi/gd/playground/text_on_transparent_background/text_aa_alpha.c?revision=1.2&view=markup Please remember that it will work for text but not other shapes. The antialiased lines always blend on the destination pixel, for now. Aha. That explains something that had been bothering me about some plots created by gnuplot. So if the user chooses TrueColor output and a transparent background,
then we have to turn off anti-aliasing for vectors. Otherwise there are ghost fringes, which I had noticed but not thought a lot about. I think this is a bug, and should be fixed. The destination pixel in my case is white [usually] with full transparency. When you antialias onto it, the transparency should be taken into account for either setting of gdImageAlphaBlending(), right? But apparently it isn't.It is the exact same problem as Andrei had with the text. It is not a bug per se but a missing feature (an annoying missing feature). It will be implemented in 2.1.0.
As it stands the counter-intuitive observation is that blending two transparent colors produces an opaque result. But only for anti-aliased lines. I'm also puzzled as to why this is true even for pure horizontal or vertical lines. Why are those affected by anti-aliasing at all?The AA functions blend only against the RGB part of the destination pixel. The axis aligned lines are not drawn using the anti-aliased function. This problem is really a pain for anyone working with transparency. 2.1.0 will add all necessary modes to all drawing functions (with or without anti-aliasing). I'm writing a proposal for new GD surfaces and mode. One of the goals is to solve many of the current confusions between the transparent color index (which is format specific) and the transparency/opacity channel in each color. I think it will reduce the confusions and make GD behaviors more user friendly.
I can provide demo output if you like.If you have one at hand, please yes. Even if I see your problem, an image is always welcome . --Pierre