Re: alpha for text?

Hi again,

On 7/16/05, Paul Pogonyshev <pogonyshev gmx net> wrote:
John Cupitt wrote:
On 7/15/05, Paul Pogonyshev <pogonyshev gmx net> wrote:
Has anyone rendered text with alpha channel (i.e. semitransparent text)
in GDK framework?  So far my best solution is to render black on white
to a GdkImage, get it back in a GdkPixbuf and then add color/transparency
manually.  Not actually too difficult, but I want to ask in case somebody
can come up with something better.

You can use pangoft2 to render text on the client side and thereby
avoid shipping images back from the server. Not much neater, but quite
a bit quicker.

Can I have a little more information here, please?  I thought GtkImage was
client side.  And if not, is your approach portable all the way back to
GTK+ 2.0?

I hope I'm not misunderstanding you here (apologies if I am), but I
think it sounds like you are rendering text to an off-screen pixmap
with gdk_draw_layout(), fetching to the client as a GdkImage, then
going to a gdkpixbuf to manipulate it. The gdk_draw_layout() is
probably rasterising the font with freetype2 client-side, then
shipping the rendered glyphs to the server. So you may well be sending
the data both ways.

If you've not seen it, have a look at pangoft2topgm.c in the pango
sources. It's a command-line program which renders text directly to a
bitmap (with no X server) using pangoft2. I used this as a base for a
text render operation in my image processing library with great
success. As far as I know, this will work on any gtk+-2.0, though I've
not tested it.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]