public void SaveLoad() { using (Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(null, "f-spot-32.png")) { Gdk.Pixbuf source = pixbuf; if (pixbuf.HasAlpha) { source = PixbufUtils.Flatten(pixbuf); } string path = ImageFile.TempPath("test.ppm"); PnmFile pnm = new PnmFile(path); using (Stream stream = File.OpenWrite(path)) { pnm.Save(source, stream); } pnm = new PnmFile(path); using (Gdk.Pixbuf saved = pnm.Load()) { Assert.IsNotNull(saved); Assert.AreEqual(saved.Width, source.Width); Assert.AreEqual(saved.Height, source.Height); } if (source != pixbuf) { source.Dispose(); } File.Delete(path); } }
public override Gdk.Pixbuf Load() { try { using (Stream stream = Open()) { Gdk.Pixbuf pixbuf = PnmFile.Load(stream); return(pixbuf); } } catch (System.Exception e) { System.Console.WriteLine(e.ToString()); } return(null); }
public void SaveLoad () { using (Gdk.Pixbuf pixbuf = new Gdk.Pixbuf (null, "f-spot-32.png")) { Gdk.Pixbuf source = pixbuf; if (pixbuf.HasAlpha) source = PixbufUtils.Flatten (pixbuf); string path = ImageFile.TempPath ("test.ppm"); PnmFile pnm = new PnmFile (path); using (Stream stream = File.OpenWrite (path)) { pnm.Save (source, stream); } pnm = new PnmFile (path); using (Gdk.Pixbuf saved = pnm.Load ()) { Assert.IsNotNull (saved); Assert.AreEqual (saved.Width, source.Width); Assert.AreEqual (saved.Height, source.Height); } if (source != pixbuf) source.Dispose (); File.Delete (path); } }