[cairo] RFC: an cairo image operator - cairo_image()

Arjen Nienhuis a.g.nienhuis at gmail.com
Tue Apr 20 04:40:33 PDT 2010


*Proposal:
*
Implement an image operator for cairo.

It's possible to draw an image (the contents of an Image Surface) onto a
cairo surface with the following code:

cairo_translate(...);
cairo_scale(...);
cairo_set_source(...);
cairo_paint(...);

I'd like to propose to replace that with a single call to:

cairo_image(cr, src, x, y, width, height);

Both SVG and PDF have this operator but Cairo has not.

*C Prototype:
*
cairo_image(
       cairo_t *cr,
       cairo_surface_t *source_image_surface,
       double x,
       double y,
       double width,
       double height);

*Implementation:*

1: make a fallback wrapper like:

cairo_save();
cairo_translate(...);
cairo_scale(...);
...something about EXTEND...
cairo_set_source(...);
cairo_paint(...);
cairo_restore();

2: For SVG and PDF (PS?) backends implement it with the native image
operators: <svg:image ...> and PDFs /Image. Now images are always pattern
fills.

*Pros:
*
- More readable code
- Cleaner PDF and SVG files
     - Easier to edit with external tools (Inkscape, Acrobat)
     - Processed faster by RIPs.
     - This makes better round trips through poppler and rsvg.
     - Counter: this can be done now by special casing some cairo_fill()calls.
         - Counter: this seems hard

*Cons:
*
- Larger external API needs to be maintained
    - Counter: why implement cairo_rectangle() if you have cairo_line_to()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20100420/0eb45ce6/attachment.html>


More information about the cairo mailing list