[cairo] shadow of transparent png image

M Joonas Pihlaja jpihlaja at cc.helsinki.fi
Sat Dec 27 19:40:06 PST 2008


On Sat, 27 Dec 2008, Dusan Halicky wrote:

> I have transparent png image. Can I somwhow in cairo draw it's shadow?
> I mean not rectangular shadow of picture, but shadow of it's contents.
> I was thinking about another surface - copy of original - but darken
> to black color and displayed behind original surface. However I don't
> know how to make this "darken" effect in cairo. Thanks.

The ATOP operator is great for darkening.  It maintains the alpha 
of the destination but blends in the colour of the source by the 
source alpha.  So painting with semitransparent black to your 
image copy with operator ATOP would darken it.  If instead of a 
copy you use a semitransparent copy as the destination then the 
shadow will be a little transparent too.

http://people.freedesktop.org/~joonas/shadow/out-shadow.png

http://people.freedesktop.org/~joonas/shadow/shadow.c

Cheers,

Joonas


More information about the cairo mailing list