[cairo] Enabling GTK drawing area alpha channel
Emmanuel Thomas-Maurin
manutm007 at gmail.com
Mon May 16 15:07:03 PDT 2011
Hi everybody,
While drawing onto a GTK drawing area from a cairo image surface, it
seems the alpha channel is gone.
Creating the cairo image surface:
surf = cairo_image_surface_create(
CAIRO_FORMAT_ARGB32, surf_width, surf_height);
cr = cairo_create(surf);
/* draw background */
cairo_set_source_rgba(cr, red, green, blue, alpha);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_paint(cr);
/* draw foreground */
cairo_set_source_rgba(cr, red, green, blue, alpha);
pango_cairo_update_layout(cr, p_layout);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
pango_cairo_show_layout(cr, p_layout);
Drawing from surface to gtk_drawing_area:
cr = gdk_cairo_create(GDK_DRAWABLE((drawing_area)->window));
cairo_set_source_surface(cr, surf, - x, 0);
cairo_rectangle(cr, 0, 0, drwa_width, drwa_height);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_fill(cr);
cairo_destroy(cr);
The cairo surface format is created as 32-bit with an alpha channel.
Then the drawing area seems to have a 24-bit format
(gdk_visual_get_system()->depth = 24).
My question is: Is it possible to have a 32-bit depth or to enable
transparency for GTK drawing areas (other than gtk_window_set_opacity()
for the whole window) ?
Thanks for any hints.
--
Emmanuel Thomas-Maurin <manutm007 at gmail.com>
More information about the cairo
mailing list