Thanks for the reply!<br><br><br><div class="gmail_quote">On Dec 13, 2007 8:12 PM, Carl Worth <<a href="mailto:cworth@cworth.org">cworth@cworth.org</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Thu, 13 Dec 2007 19:44:10 +0100, "Tuom Larsen" wrote:<br>> I'm very new to Cairo, please bear with me:<br><br></div>Hi Tuom, welcome to cairo!<br><div class="Ih2E3d"><br>> - I don't really get the concept of Surfaces - can I convert between various
<br>> surfaces? Say from Image to PDF? How? Create an Image, Create a PDF with the<br>> same dimensions and call cairo_paint? (btw, I'm using pycairo)<br><br></div>Yes, you can copy from one surface to another and you just described
<br>how to do it, (along with cairo_set_source_surface). See:<br><br> <a href="http://cairographics.org/FAQ/#paint_from_a_surface" target="_blank">http://cairographics.org/FAQ/#paint_from_a_surface</a><br><br>Is there somewhere we could add a pointer to that page so you would
<br>have found it? Or had you found that page and there's something we<br>could do to make it more clear?</blockquote><div><br>I found that page - I was just not sure whether this is the right way of converting between various surfaces and if one shouldn't use some kind of (binary) stream object instead. In another words, I was looking for "convert" instead of "copy". However, you introduced another question - more on that bellow, please.
<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br><div class="Ih2E3d"><br>> - Is there a generic/meta Surface I'm drawing to, and all the other Surfaces
<br>> (Image, PDF) provide "mere" disk serialization in the format<br>> specified?<br><br></div>There is a meta surface, (which is precisely what it's called in the<br>cairo internals), for things like the PDF, PostScript, and SVG
<br>backends, (and win32-printing). And yes, those simply do<br>serialization.<br><br>But for the image backend, the meta-surface is not involved, and every<br>drawing operation results immediately in changes to the pixel
<br>buffer. Similarly, for xlib, quartz, and win32 backends, each drawing<br>operation results immediately in some call to the underlying system to<br>do some actual drawing, (no meta-surface involved).</blockquote><div><br>
If I understand correctly (maybe I even read it somewhere), there are basically to "kinds" of surfaces - the ones which do preserve drawing operations (PDF, SVG, ...) and the ones which do not (xlib, image, ...). Is it so?
<br><br>Then, the another question is, if I draw to Image surface and duplicate it via the method from FAQ to PDF surface, what happens? In PDF, will there be an embeded pixel-image or all the vector-paths and lines and curves which were used to draw the Image surface? Because, sorry if I'm misunderstading you, it seems to me now, that in PDF there will be that pixel image, instead of vector-paths as I originally thought. And that's also how it comes to the question how to convert between surfaces.
<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br><div class="Ih2E3d"><br>> If so, is it also possible to serialize this generic Surface?
<br><br></div>There's no cairo-specific serialization. But you can serialize to PDF,<br>PostScript, or SVG. Note that after you do that, cairo itself doesn't<br>provide de-serialization for you. But the poppler library can
<br>de-serialize PDF files to cairo operations, and librsvg does the same<br>for SVG files. We don't currently have a good option for PostScript to<br>cairo though.<br><div class="Ih2E3d"><br>> And if not, how can I store an Image Surface and the load it some
<br>> another time?<br><br></div>For any surface type, (not just image surfaces), you can save a<br>rasterized version of the content with cairo_surface_write_to_png and<br>load it later with cairo_image_surface_create_from_png.
</blockquote><div><br>My original thought was that I will create an Image (or meta) surface, do all the drawing, then serialize this surface via programming language (e.g. in python via pickle) and then reuse. In that way i wouldn't need to use Poppler or librsvg.
<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br><div class="Ih2E3d"><br>> Thanks a lot in advance!<br><br></div>You're welcome. Do have lots of fun with cairo!
</blockquote><div> </div><div>Thanks! <br></div><div> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br><br>And let us know if there are things you see that could be added to the
<br>FAQ or to other documentation.</blockquote><div><br>Well, the mailing list archive is pretty good and the site too, but since you asked :).. Maybe a wiki and some more diagrams would be useful but now I see that both are being worked on. So, actually, nothing really. ... Ok, one thing: I found a tiny bit confusing all this "samples", "recipes", "snippets", "examples" - I wasn't really sure where to look for what.
<br><br> <br>Thanks once more!<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br><font color="#888888"><br>-Carl<br></font></blockquote>
</div><br>