Reputation: 4199
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.
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?
or
Upvotes: 5
Views: 1228
Reputation: 113370
First of all, using C or Vala instead of Python will probably speed things up.
As for memory usage, I would try writing to my own stream, rather than a file (see write_to_png_stream). This could allow you to (I didn't try this) control memory usage, assuming Cairo doesn't call your function only once after everything's done.
Upvotes: 2