On 8/25/18 10:16 PM, Russel Winder wrote:

I want to create a Pixbuf from SVG data read at compile time. It is easy to load a file at run time, but that means installing the file. Most GTK builder constructors for menus and UIs have a way of using immediate string data, but the GDK Pixbuf appears not to have such a thing – unless I just missed it?

Has any found a way of loading SVG images into a Pixbuf using immediate data from compile time (i.e. a string import of an SVG file)?

You have two options to load the SVG form a string:

Using rsvg.Hande:

Handle img = new Handle(cast(ubyte[])yourSVG);
Pixbuf pixbuf = img.getPixbuf();

or use gdkpixbuf.PixbufLoader:

PixbufLoader loader = new PixbufLoader();

loader.write(cast(char[])yourSVG);

loader.close();

Pixbuf pixbuf = loader.getPixbuf();