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

Arjen Nienhuis a.g.nienhuis at gmail.com
Fri Apr 23 07:57:14 PDT 2010


Poll results so far:

Yes:
  0.4%

No:
  0.4%

I don't care:
  99.2%

On Tue, Apr 20, 2010 at 1:40 PM, Arjen Nienhuis <a.g.nienhuis at gmail.com>wrote:

> *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/20100423/55a43b5f/attachment-0001.htm>


More information about the cairo mailing list