title: Big images with cairo
body: <p>I have to render a very big image (>50.000² pixel) with cairo. To do this without running out of memory I render parts of the image (&lt;1.000² pixel) one after another and merge them together later.</p>
  
  <ol>
  <li>Create 1000x1000 Surface</li>
  <li>Translate to position of the current part</li>
  <li>Draw image (calling the drawing instructions using pycairo)</li>
  <li>Render/Save image to file (cairo_surface_write_to_png)</li>
  <li>Repeat with next part</li>
  </ol>
  
  <p>Because cairos clipping algorithms are faster than my own, step three draws the whole image, even if only a part of it is visible. Most of the CPU is used in Step 3 (by python). Most of the memory is used in Step 4 (by cairo).</p>
  
  <p>Is there a way to speed things up? Something like this?</p>
  
  <ol>
  <li>Create 1000x1000 Surface</li>
  <li>Draw image</li>
  <li>Move everything to position of the current part</li>
  <li>Render/Save image to file</li>
  <li>Repeat 3 with next part</li>
  </ol>
  
  <p>or</p>
  
  <ol>
  <li>Create 50000x50000 Surface</li>
  <li>Draw image</li>
  <li>Render/Save only the current part of the image to file</li>
  <li>Repeat 3 with next part</li>
  </ol>