I have an album title of some music band. I want to draw it with some mask which will round the corners of image. So, I've prepared such mask in gimp:
I'm using white mask, but it's invisible at white background here. So, here is the code of rendering:
# Draw album image
img = cairo.ImageSurface.create_from_png('images/album.png')
ctx.set_source_surface(img, posX, posY)
ctx.paint()
# Draw mask
ctx.set_operator(cairo.OPERATOR_DEST_IN)
img = cairo.ImageSurface.create_from_png('images/mask.png')
ctx.set_source_surface(img, posX, posY)
ctx.paint()
As you see, I've used OPERATOR_DEST_IN
. Quick examples I found at this page.
But, everything disappeared in my program when I set compositing operator in cairo :(. When I comment that line everything is okay, but mask is over my image. What is the right way for that?
p.s. I'm using python2, cairo library
When I remove compositing operator I see (don't forget that real mask is white, in this case album image is dark):