Linux.com

cairo draw over alpha

Link to this post 03 Jun 11

Hi, I'd like to draw with cairo over a surface of a GtkDrawingArea. My problem is that drawing over the surface doesn't draw a solid color over a color with alpha channel. I don't use any special cairo operators and the result is that I see some unneeded rectangles with alpha channel where there shouldn't be any.


cr = gdk_cairo_create(GTK_WIDGET(editor->drawing_area)->window);
cairo_push_group(cr);

cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
cairo_rectangle(cr, 0.0, 0.0, (double) widget->allocation.width, (double) widget->allocation.height);
cairo_fill(cr);

/* do some other drawing */

/* draw with alpha channel */
cairo_set_source_rgba(cr, 0.25, 0.5, 1.0, 0.5);
cairo_rectangle(cr, (double) x, (double) y, (double) width, (double) height);
cairo_fill(cr);

/* pop it to source */
cairo_pop_group_to_source(cr);
cairo_paint(cr);

Link to this post 05 Jun 11

I'm sorry. I've finally found the mistake. If you're interested in what went wrong you can look at revision 322 http://ags.svn.sourceforge.net/viewvc/ags/

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board