[cairo] Loading SVG from memory using RSVG

Daniel Amelang daniel.amelang at gmail.com
Sun Dec 3 15:55:15 PST 2006


On 12/3/06, Simon Flannery <simon_flannery at yahoo.com.au> wrote:
> Hi,
>
> Loading and rendering a SVG from a file was error free, but how do you load and render a SVG from a chunk of memory?
>
> For example:
>
> ..
> const unsigned char* data = (const unsigned char*) "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"><desc>Simple Polygon Test</desc><polygon fill=\"#69c2d4\" stroke=\"#facd2d\" stroke-width=\"7\" points=\"119,0 148,86 238,86 166,140 192,226 119,175 46,226 72,140 0,86 90,86\" /></svg>"; // should render a star.
> ..
> g_my_svg = rsvg_handle_new_from_data(data, sizeof(data), &pError);
> MessageBox(NULL, pError->message, "Error", 0); // Always says "Error parsing XML data"
> ..
>
> I can load the exact same XML / SVG from a file and get cario to render it, but no luck from memory. Any Ideas, Help?

The rsvg list is here:

http://lists.sourceforge.net/lists/listinfo/librsvg-devel

But, for what it's worth, I think what you're looking for is rsvg_handle_write.

Dan


More information about the cairo mailing list