[cairo] how to make existing color transparent

Behdad Esfahbod behdad at behdad.org
Thu Feb 5 18:05:18 PST 2009


Pablo Romero wrote:
> Is it possible to set the alpha transparency on an existing color within
> a surface, and cause that color & anything beneath it to have 0 alpha,
> completely transparent???
>  
> example:
> I want to draw a purple rectangle on a surface, over existing image data.
> Next, I want to make that rectangle completely transparent in the
> resulting png file (i.e., 'set any/all areas that are purple to 100%
> transparent on cairo_surface_t *surface'). I dont want any existing
> colors/graphics that were below the rectangle to show up.
>  
> I tried using "set_source_rgba" and setting the alpha to '0.0', but this
> doesnt cause the underlying colors/images to become transparent...

You need to use the CAIRO_OPERATOR_SOURCE instead of the default operator
which is CAIRO_OPERATOR_OVER.


behdad


> How can I achieve this effect? similar to gd's "gdImageColorTransparent"
> function...
> Please help...
> Thanks,
> P.Romero
> 
> 
> ------------------------------------------------------------------------
> Windows Live™: E-mail. Chat. Share. Get more ways to connect. Check it
> out.
> <http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_AE_Faster_022009>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo


More information about the cairo mailing list