[Gtk-sharp-list] Rendering SVG files with RSVG in GTK#
David Abrames
abramesd at kmbs.konicaminolta.us
Wed Oct 25 07:44:13 EDT 2006
Hello,
I am trying to render an SVG XML file into a png image using the RSVG
functions within GTK#. The application is a non GUI application and I am
having a problem initializing GTK properly. The following code represents
what I am trying to do, I want to take a svg xml file and render it as a png
image and save the png image as a new file to be used later in my
application.
using System;
using Gtk;
namespace renderSVG
{
class Program
{
static void Main(string[] args)
{
Gdk.Pixbuf pixbuf = Rsvg.Pixbuf.FromFile(args[0]); // the file on the
command line
pixbuf.Save("Chart.png", "png");
}
}
}
When I run this program with a valid svg xml file as input I get the
following error:
(./renderSVG.exe:27905): GLib-GObject-CRITICAL **: gtype.c:2215:
initialization assertion failed, use IA__g_type_init() prior to this
function
(./renderSVG.exe:27905): GLib-GObject-CRITICAL **: gtype.c:2215:
initialization assertion failed, use IA__g_type_init() prior to this
function
(./renderSVG.exe:27905): GLib-GObject-CRITICAL **: g_object_new: assertion
`G_TYPE_IS_OBJECT (object_type)' failed
Unhandled Exception: GLib.GException: Error creating SVG reader
in <0x00080> Rsvg.Pixbuf:FromFile (System.String file_name)
in <0x0004c> renderSVG.MainClass:Main (System.String[] args)
I tried using the Gtk.Application.Init() method and this works in the simple
program above but causes my main application to crash. The application is a
web application written in C# and compiled using Mono on Ubuntu 6.06.
I figure my problem has to do with initializing GTK properly but I can't
figure out what I need to do. Any help or suggestions would be appreciated.
David
More information about the Gtk-sharp-list
mailing list