[OSM-talk] SVG to PNG without burning lots of memory
Simon Hewison
simon at zymurgy.org
Mon Jul 24 20:10:41 BST 2006
Ronan Oger wrote:
> Here are some more SVG to PNG options:
>
> 1) batik rasteriser
> 2) ksvgtopng on (kde)
>
> Regarding your 7MB of xml bloat... You may consider (1) optimizing your LOD
> (level of detail) to best match the expected screen size before generating
> the svg image. (2) optimizing the SVG output for the smallest possible
> content (3) gzipping the svg.
>
> If you want to send me a sample of the output, I can take a look at it and
> offer you some hints.
>
> Your big problem is that SVG needs the entire document modelled in ram as a
> canvas before it can proceed and dump the contents to screen. Crazy-high
> resolution in the data causes crazy-high memory usage.
Okay, even if SVG is using a Document Object Model, then 7MB of XML
bloat should become less than 7MB in RAM. That's no big deal. I've got
many orders of magnitude more than that on my desktop machine. Gzipping
the SVG will NOT help the memory footprint when the renderer models the
entire lot into it's in-memory structures, since the first thing it will
do is decompress it.
As for the memory footprint for a 32 bit uncompressed bitmap for it to
render into, that's still not a huge amount of memory these days. It was
a decade and half ago when laser printers had the same problem. 4 bytes
per pixel x 2048 x 1538 resolution is still only just a bit over 12MB..
So why can't I take my 7MB of (xml padded) data into RAM, and turn it
into a 12MB canvas without burning over 250MB of RAM?
It seems that software authors have forgotten the concept of efficient
coding these days. If I had the time, I'd sit down and write an
efficient SVG renderer. Sadly, I haven't the time.
--
Simon Hewison
More information about the talk
mailing list