<b>Proposal:<br></b><br><div>Implement an image operator for cairo.<br><br>It's possible to draw an image (the contents of an Image Surface) onto a cairo surface with the following code:<br><br><font class="Apple-style-span" face="'courier new', monospace">cairo_translate(...);<br>
cairo_scale(...);<br>cairo_set_source(...);<br>cairo_paint(...);<br></font><br>I'd like to propose to replace that with a single call to:<br><br><font class="Apple-style-span" face="'courier new', monospace">cairo_image(cr, src, x, y, width, height);</font></div>
<div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br></font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">Both SVG and PDF have this operator but Cairo has not.<br><br>
</font><b><font class="Apple-style-span" face="arial, helvetica, sans-serif">C Prototype:</font><br></b><br><font class="Apple-style-span" face="'courier new', monospace">cairo_image(<br> cairo_t *cr,<br> cairo_surface_t *source_image_surface,<br>
double x,<br> double y,<br> double width,<br> double height);<br></font><br></div><div><b>Implementation:</b></div><div><br></div><div>1: make a fallback wrapper like:</div><div><br></div><div>
<font class="Apple-style-span" face="'courier new', monospace">cairo_save();</font></div><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">cairo_translate(...);<br>cairo_scale(...);<br>
</span><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">...something about EXTEND...</span></div><div><font class="Apple-style-span" face="'courier new', monospace">cairo_set_source(...);<br>
cairo_paint(...);</font></div><div><font class="Apple-style-span" face="'courier new', monospace">cairo_restore();<br></font><br></div><div>2: For SVG and PDF (PS?) backends implement it with the native image operators: <font class="Apple-style-span" face="'courier new', monospace"><svg:image ...></font> and PDFs <font class="Apple-style-span" face="'courier new', monospace">/Image</font>. Now images are always pattern fills.</div>
<div><br></div><div><b>Pros:<br></b><br>- More readable code<br>- Cleaner PDF and SVG files</div><div> - Easier to edit with external tools (Inkscape, Acrobat)</div><div> - Processed faster by RIPs.</div><div> - This makes better round trips through poppler and rsvg.</div>
<div> - Counter: this can be done now by special casing some <font class="Apple-style-span" face="'courier new', monospace">cairo_fill()</font> calls.</div><div> - Counter: this seems hard</div><div><br>
<b>Cons:<br></b><br>- Larger external API needs to be maintained</div><div> - Counter: why implement <font class="Apple-style-span" face="'courier new', monospace">cairo_rectangle()</font> if you have <font class="Apple-style-span" face="'courier new', monospace">cairo_line_to()</font></div>