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

Travis Griggs tgriggs at cincom.com
Tue Apr 20 23:44:23 PDT 2010


On Apr 20, 2010, at 4:40 AM, Arjen Nienhuis 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()

My naive first pass response is "two thumbs up."

--
Travis Griggs
Objologist
"An idea, like a ghost, must be spoken to a little before it will  
explain itself." - Charles Dickens

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20100420/b0723e63/attachment.html>


More information about the cairo mailing list