[Gtk-sharp-list] new Gdk.Pixbuf (svg_stream) fails on windows but works on unix
Stephane Delcroix
stephane at delcroix.org
Tue Oct 21 02:45:03 EDT 2008
Hi,
Gdk contains some helpers to load pixbufs from resources:
Pixbuf loaded_from_res = Gdk.Pixbuf.LoadFromResource
("resourcename.png");
But that's unrelated to your problem. In your case, it looks like the
gdk_pixbuf you're using on windows is not compiled with svg support.
You can list the supported formats in gdk_pixbuf by a code like this:
foreach (PixbufFormat format in Pixbuf.Formats)
Console.WriteLine (format.Name);
regards
s
On Sun, 2008-10-19 at 06:04 -0700, thomas_wach wrote:
> Hello,
>
> I am working with mono-2.0 an Linux (fc8) and Windows XP(SP3). I use
> monodevelop 1.0. Everything compiled from source on my Linux box rund fine.
> On my Windows box the provided setup mono-2.0-gtksharp-2.10.4-win32-5.exe
> ist correctly installed and mods done to the mono-config file.
>
> I created some SVG-icons with inkscape (icon_64x64), saved them to the
> project folder and imported them as resources with monodevelop.
>
> Here is the code that populates my combobox-store with the icons I need:
>
> System.Reflection.Assembly ass =
> System.Reflection.Assembly.GetExecutingAssembly();
> string[] resNames = ass.GetManifestResourceNames();
> foreach (string resItemName in resNames) {
> try
> {
> if (resItemName.StartsWith("shape-") && (resItemName.EndsWith(".svg")
> || resItemName.EndsWith(".png"))) {
> System.IO.Stream s = ass.GetManifestResourceStream(resItemName);
> store.AppendValues (" #" + resItemName.Substring(6,1) + " ", new
> Gdk.Pixbuf(s));
> }
> }
> catch (Exception e)
> {
> DebugMessage (e.ToString());
> }
> }
>
> This works PERFECT on my Linux box.
>
> BUT on my Windows box I get the following error whem it tries to open a
> .svg-file:
>
> GLib.GException: Format der Bilddatei unbekannt (format of picturefile
> unknown)
> at Gdk.PixbufLoader.Close () [0x00000]
> at Gdk.PixbufLoader.InitFromStream (System.IO.Stream stream) [0x00000]
> at Gdk.PixbufLoader..ctor (System.IO.Stream stream) [0x00000]
> at Gdk.Pixbuf..ctor (System.IO.Stream stream) [0x00000]
> at GladeApp..ctor (System.String[] args) [0x00000]
>
> Creating the pixbuf from the .png-icons contained in the manifested resource
> works on both boxes!
> Only the SVG-files do not.
>
> The Windows box is PURE mono, so NO .NET 1.1 nor .Net 2.0 are installed
> there.
> So the gtksharp-sdk-2.10.3.exe is NOT installed, because it depends on .NET
> 1.1.
>
> By the way, if I try to directly create a pixbuf with the FromFile-Method it
> throws exceptions regarding a missing librsvg-2. But that IS NOT the case.
> librsvg-2-2.dll and librsvg-2.dll (size 251kb) are correctly residing in
> %MONOPATH%\bin !
>
> Of course I searched the net, but all hints I found did not solved the
> problem.
> - prior call Gtk.Application.Init() -> no change
> - referencing Mono.Cairo in the project -> no change
> - found some articels talking about a librsvg2-common, but find no valid
> dll for win32 to setup or copy
>
> Maybe the SVG-files themselves have some issues regardin DOCTYPE, DTD or
> something else?
> I do not think that the different line breaks in unix/windows are
> responsible, do you?
>
> Here is the header of the a sample SVG-file that does not load on windows:
> (the complete SVG-file is attached)
> http://www.nabble.com/file/p20055917/shape-1.svg shape-1.svg
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <!-- Created with Inkscape (http://www.inkscape.org/) -->
> <svg
> xmlns:dc="http://purl.org/dc/elements/1.1/"
> xmlns:cc="http://creativecommons.org/ns#"
> xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
> xmlns:svg="http://www.w3.org/2000/svg"
> xmlns="http://www.w3.org/2000/svg"
> xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
> xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
> width="64px"
> height="64px"
> id="svg2383"
> sodipodi:version="0.32"
> inkscape:version="0.46"
> sodipodi:docname="shape-1.svg"
> inkscape:output_extension="org.inkscape.output.svg.inkscape">
>
>
> I think I provided every information needed, but let me know, if I missed
> some important.
>
> Anyone got the same problem and get rid of it?
> Anyone knows about special SVG-issues that could lead to this behaviour?
>
> So far ...
> Kind regards
> Thomas
More information about the Gtk-sharp-list
mailing list