<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Apr 20, 2010, at 4:40 AM, Arjen Nienhuis wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><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></blockquote><br></div><div>My naive first pass response is "two thumbs up."</div><br><div> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>--</div><div>Travis Griggs</div><div>Objologist</div><div>"An idea, like a ghost, must be spoken to a little before it will explain itself." - Charles Dickens </div></div></span></div></span> </div><br></body></html>