RE: [GD-DEVEL] Rendering Transparent Text?
| From: | Colen Garoutte-Carson | Date: | Sat, 20 Dec 2008 14:08:07 +0000 |
| Subject: | RE: [GD-DEVEL] Rendering Transparent Text? | ||
| References: | 1 2 3 | Groups: | php.gd.devel |
| Request: | Send a blank email to php-gd-devel+get-530@lists.php.net to get a copy of this message | ||
Hi Rob,
If you disable alpha-blending, all drawing (including alpha) is
applied directly without blending. That would let you 'cut out' text in a
PNG. Though, it doesn't look like GD (freetype?) will handle the
anti-aliasing in an 'ideal way'. To really handle this properly, GD would
need 2 more blending modes.
(#1 - Blend)
(#2 - Don't Blend)
#3 - Blend, w/alpha
Increase/decrease existing alpha.
i.e. alpha=100 drawn on alpha=0 would result in
alpha=50.
#4 - Blend only AA pixels, w/alpha
This would allow direct application of alpha to the
image, but allow proper anti-aliasing to occur by increasing/decreasing the
alpha of AA pixels.
Short of writing custom drawing primitives, you might try drawing
solid text on a transparent background, then inversing the alpha of each
pixel. That should preserve the AA.
- Colen
-----Original Message-----
From: sgreth@gmail.com [mailto:sgreth@gmail.com] On Behalf Of SGreth
Sent: Saturday, December 20, 2008 5:15 AM
To: Pierre Joye
Cc: gd-devel@lists.php.net
Subject: Re: [GD-DEVEL] Rendering Transparent Text?
Hi Pierre,
Unfortunately I wasn't trying to render text with a a transparent
background but rather render text transparent. Take a black canvas, then
render text on it, which would 'cut out' of the black canvas and thus be
transparent. The end result being something that looked like a stencil.
Thanks!
~Rob
On Sat, Dec 20, 2008 at 2:42 AM, Pierre Joye <pierre.php@gmail.com> wrote:
> hi!
>
> On Sat, Dec 20, 2008 at 4:35 AM, SGreth <sgreth@sgreth.com> wrote:
> > Hello everybody,
> > I've been scouring Google and I have yet to find anybody who's
> answered
> > the question if you can render transparent text with GD. Think of
> creating a
> > PNG "stencil" if you will. Take an image that's all black, and then
> > "cut
> > out" some text on it by rendering some transparent text. I've been
trying
> > all sorts of combinations with imagecolortransparent() to no avail. Any
> > insight if I'm chasing a pipe-dream would be greatly appreciated.
>
>
> See
>
http://cvs.php.net/viewvc.cgi/gd/playground/text_on_transparent_background/
>
> It is in C but the PHP API is very closed :)
>
>
> Cheers,
> --
> Pierre
>
> http://blog.thepimp.net |
> http://www.libgd.org
>
> --
> GD Devel Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>