[Gtk-sharp-list] Gdk.Pixbuf
Parrish M Myers
parrishmyers@yahoo.com
Tue, 20 May 2003 14:48:43 -0700 (PDT)
I'm sorry to bother you again... but I just tried it and it still
doesn't work for me:
Unhandled Exception: System.NullReferenceException: A null value was
found where an object instance was required
in <0x00090> 00 Gdk.Pixbuf:LoadFromStream (System.IO.Stream)
in <0x000aa> 00 Gdk.Pixbuf:.ctor (System.Reflection.Assembly,string)
in <0x000ca> 00 .Test:.ctor ()
in <0x00027> 00 .Test:Main (string[])
The only way I can get it to work is to take the null out of the
parameters and include the image in the current directory.
BTW... I am running this on a redhat 9 system with mono 0.24 and
gtk-sharp 0.9.
I didn't change your source code.
--- McP <mariano.cano@hispalinux.es> wrote:
> This code works:
>
> using System;
> using Gtk;
> using GtkSharp;
> using Gdk;
> class Test {
>
> Test()
> {
> Gtk.Window window = new Gtk.Window("Test");
> window.DeleteEvent += new DeleteEventHandler(Window_Delete);
> Pixbuf pixbuf = new Pixbuf(null,"image.png");
>
> try{
> window.Add(new Gtk.Image(pixbuf));
> }catch(Exception e)
> {
> Console.WriteLine("Excepcion");
> Console.WriteLine(e);
> }
> window.ShowAll ();
> }
>
> static void Window_Delete (object obj, DeleteEventArgs args)
> {
> Application.Quit ();
> }
>
> public static void Main(string[] args)
> {
> Application.Init ();
> new Test();
> Application.Run ();
> }
> }
>
>
> $ mcs -resource:image.png main.cs -r gtk-sharp -r gdk-sharp
> $ mono main.exe
>
> El lun, 19 de 05 de 2003 a las 02:27, Parrish M Myers escribió:
> > --- McP <mariano.cano@hispalinux.es> wrote:
> > > > Pixbuf pixbuf = new Pixbuf ("lcd.png");
> > > > CanvasPixbuf item = new CanvasPixbuf(lcd_canvas.Root());
> > > > item.Pixbuf = pixbuf;
> > > >
> > > > This works great... but I have to include the png file in the
> > > current
> > > > directory when running the app. If I try to include the file
> in
> > > the
> > > > resource string when compiling, i.e.
> > > >
> > > > mcs ... -resource:lcd.png ...
> > > >
> > >
> > > Try
> > > Pixbuf pixbuf = new Pixbuf(null, "lcd.png");
> > > ....
> > >
> > > Now you could store the file inside the assembly as a resource
> >
> > That seems to produce this error when the resultant exe is
> created..
> > Am I including the resource improperly? I added
> > -resource:lcd.png
> > to the 'mcs' command...
> >
> > Unhandled Exception: System.NullReferenceException: A null value
> was
> > found where an object instance was required
> > in <0x00090> 00 Gdk.Pixbuf:LoadFromStream (System.IO.Stream)
> > in <0x000aa> 00 Gdk.Pixbuf:.ctor
> (System.Reflection.Assembly,string)
> > in <0x000fe> 00 SwTimer.MainWindow:.ctor (ModeType)
> > in <0x00198> 00 SwTimer.SwTimer:.ctor (string[],object[])
> > in <0x00042> 00 SwTimer.SwTimer:Main (string[])
> >
> >
>
> --
> McP <mariano.cano@hispalinux.es>
>
> _______________________________________________
> Gtk-sharp-list maillist - Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
=====
-----------------------------------------------------------
Academia is a little like child | Parrish M. Myers
rearing, it provides a chance at | The Wacked Jester
immortality without the stretch | parrishmyers@yahoo.com
marks -- (unknown source) |
-----------------------------------------------------------
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com