Bonjour,
j'ai développé une application en c# utilisant mono, glade et les Pixbuf de Gdk.
Sous linux (ubuntu 8.10), tout se passe bien.
La ligne suivante passe très bien :
Gdk.Pixbuf pix = new Pixbuf("/Path_to_the_image/imageSVG.svg");
le pixbuf est bien chargé, rien à dire.
Mais depuis peu, j'essaie de porter mon application sous windows (on dit que mono est multiplateforme, et j'ai envie de proposer mon appli aux windowiens).
J'ai tant bien que mal réussi à faire marcher mon application, mais malheureusement, les Gdk.Pixbuf sous windows me refuse totalement la lecture de fichiers SVG.
La ligne suivante :
Gdk.Pixbuf pix = new Pixbuf("C:/Path_to_the_image/imageSVG.svg");
me donne une erreur de type :
1 2 3 4 5
|
Exception in Gtk# callback delegate
Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> GLib.GException: Impossible de reconnaître le format d'image du fichier *C:/Path_to_the_image/imageSVG.svg*»
at Gdk.Pixbuf..ctor (System.String filename) [0x00000] |
Or pourtant, j'ai cherché sur le forum, et je suis tombé sur celui-ci : ancienne discussion : Gtk gère t-il le format d'image SVG ?
Ce post dit qu'il faut avoir dans le fichier svg_loader dans le dossier loaders de son gtk :
"sous Linux/Debian j'ai un fichier /usr/lib/gtk-2.0/2.10.0/loaders/svg_loader.so..."
Je suis sous vista, j'ai installé mono 2.2 (mono-2.2-gtksharp-2.12.7-win32-5.exe) et j'ai donc bien le fichier svg_loader.dll dans mon dossier loaders :
C:\Program Files\Mono-2.2\lib\gtk-2.0\2.10.0\loaders\svg_loader.dll
J'ai même dans le dossier module, un fichier libsvg.dll :
C:\Program Files\Mono-2.2\lib\gtk-2.0\2.10.0\engines\libsvg.dll
Lors de ma compilation, j'ajoute bien -pkg:gtk-sharp-2.0, qui normalement devrait suffire. J'ai également essayé d'ajouter rsvg-sharp-2.0 en plus, mais cela ne change rien, les pixbuf ne savent pas lire le svg.
Comment dois-je donc faire sous windows avec mono 2.2 pour pouvoir lire directement les svg via les pixbuf ?
Si un expert Gtk connait l'astuce, je suis preneur,
Merci de m'avoir lu
Edit :
J'ai refait un petit program de test :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
/*
* Created by SharpDevelop.
* User: Moi
* Date: 02/03/2009
* Time: 02:06
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using Gtk;
using System;
using Rsvg;
using Gdk;
namespace TestSVG
{
/// <summary>
/// Description of MainWindow.
/// </summary>
public class MainWindow : Gtk.Window
{
public MainWindow() : base("MainWindow")
{
DeleteEvent += new DeleteEventHandler(MainWindowDeleteEvent);
ShowAll();
Gdk.Pixbuf pixPNG = new Gdk.Pixbuf(@"C:/image.png");
Console.Out.WriteLine("PNGImage: size = " + pixPNG.Width + "x" + pixPNG.Height);
Gdk.Pixbuf pixSVG = new Gdk.Pixbuf(@"C:/image.svg");
Console.Out.WriteLine("SVGImage: size = " + pixSVG.Width + "x" + pixSVG.Height);
}
[STAThread]
public static void Main(string[] arg)
{
Application.Init();
new MainWindow();
Application.Run();
}
void MainWindowDeleteEvent(object o, DeleteEventArgs args)
{
Application.Quit();
args.RetVal = true;
}
}
} |
Je le compile et l'execute en ligne de commande (facile à reproduire) :
1 2 3 4 5 6 7 8 9 10 11 12 13
|
c:\Users\Moi\Desktop\TestSVG\TestSVG>gmcs -out:test.exe MainWindow.cs -pkg:gtk-sharp-2.0,rsvg-sharp-2.0
c:\Users\Moi\Desktop\TestSVG\TestSVG>mono test.exe
PNGImage: size = 437x352
Unhandled Exception: GLib.GException: Impossible de reconnaître le format d'image du fichier «*C:/image.svg*»
at Gdk.Pixbuf..ctor (System.String filename) [0x00000]
at TestSVG.MainWindow..ctor () [0x00000]
at TestSVG.MainWindow.Main (System.String[] arg) [0x00000]
c:\Users\Moi\Desktop\TestSVG\TestSVG> |
On voit bien que les images se chargent bien (png), mais pas le format SVG.
Si cela peut être utile pour la résolution de ce problème...
Merci
Partager