[cairo] how to use alpha blending by cairo?

lao wb laowenbo at gmail.com
Fri Jun 30 03:06:12 PDT 2006


Thanks a lot, Kristian, you are right! gdk_pixbuf_new_from_file helps to
keep the alpha channel from being ruined.
however my job not accomplished yet, now I can use gdk_pixbuf_composite do
an overall alpha blending either by cairo_paint or gdk_draw_pixbuf .  But
precisely what I need is to make alpha blending pixel by pixel, is there any
api like gdk_pixbuf_composite without an overall_alpha parameter? Can cairo
help to render an rgba pixbuf as my wish?


Laowb


2006/6/30, Kristian Høgsberg <krh at bitplanet.net>:
>
> On 6/27/06, lao wb <laowenbo at gmail.com> wrote:
> > Hi
> >    I am using GTK+ to do with my application. I have a bitmap without
> alpha
> > channel as my background, another bitmap with alpha channel to show
> above
> > through to see the background. At first, I tried to use gdk to do this,
> > still not succeed yet, always  show only the last one gdk_draw_pixbuf
> > invokes in the expose handler.
>
> To do this with cairo, you can say something like:
>
>   cr = gdk_cairo_create (widget->window);
>   gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
>   cairo_paint (cr);
>   cairo_destroy (cr);
>
> But I suspect the problem is you're loading an xpm file to a drawable
> and converting that to a pixbuf.  Consider storing the overlay image
> as a PNG file and load it using gdk_pixbuf_new_from_file().
>
> cheers,
> Kristian
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/cairo/attachments/20060630/5ac22e41/attachment.html


More information about the cairo mailing list