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 (<1.000² pixel) one after another and merge them together later.
- Create 1000x1000 Surface
- Translate to position of the current part
- Draw image (calling the drawing instructions using pycairo)
- Render/Save image to file (cairo_surface_write_to_png)
- Repeat with next part
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).
Is there a way to speed things up? Something like this?
- Create 1000x1000 Surface
- Draw image
- Move everything to position of the current part
- Render/Save image to file
- Repeat 3 with next part
or
- Create 50000x50000 Surface
- Draw image
- Render/Save only the current part of the image to file
- Repeat 3 with next part