Tint a semi-transparent image surface with cairo

I have a background drawing and on top, I render small shaped images (pixbufs). Those images can have arbitrary value of transparency. When I give it a tint like this:

/* ....Render image... */
cairo_set_operator(cr, CAIRO_OPERATOR_MULTIPLY);
cairo_set_source_rgb(cr, r, g, b);
cairo_mask_surface(cr, imageSurface, x, y); /* xy render position */

if the image is transparent (especially eveident if the image is fully transparent) the background is naturally also tinted with the shape of the image. So I use groups to isolate the image rendering and tint with the rest of the background drawing and it works, except that there are leftovers on the image edges that look really ugly -
It does not seem to do well on the edges, they look blured and usually with a white color. I have NO idea why is this happening. Any ideas?

Maybe try using cairo_set_source_rgba(cr, r, g, b, a);
where a = 1.0 is opaque, a = 0.0 is transparent, while 0.0 < a < 1.0 gives translucency

I solved the problem by drawing in a separate context on a separate surface colorized and then drawn on the main cotext with transparency and position

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.