[cairo] Paint image in overlay mode

Lobais lobais at gmail.com
Thu Nov 9 11:48:06 PST 2006


Hi, I'm trying to paint an image in gimp "overlay" mode.
I've found the algorithm for overlay:

* Perform an RGB[A] overlay operation between the pixel sources
* ctx->A and ctx->B, using the generalized algorithm:
* D =  A * (B + (2 * B) * (255 - A))

But I don't know where to go from that. Is there some kind of filter
feature in cairo, that runs a function on all pixels?

I think I need to create an offscreen image, and update that one each
time the user changes the gtk theme (not very often)

Right now, I paint the image using this code:

cr = widget.window.cairo_create()
surface = cairo.ImageSurface.create_from_png(imgpath)
cr.rectangle (event.area.x, event.area.y, event.area.width,
event.area.height)
cr.set_source_surface(surface, 0, 0)
pattern = cr.get_source()
pattern.set_extend(cairo.EXTEND_REPEAT)
cr.fill()

Yes it is python code, but I guess the way it works is the same.

Can I somehow create an offscreen surface, that I can paint in the
backgroundcolor and append that overlay algorithm?

Also how do I get the pixeldata from the imagesurface?

-- 
Best Regards, Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/cairo/attachments/20061109/83146948/attachment.htm


More information about the cairo mailing list