[f-spot/rubenv-gsoc-2009: 81/86] Remove a ton of unused stuff in PnmFile.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot/rubenv-gsoc-2009: 81/86] Remove a ton of unused stuff in PnmFile.
- Date: Sun, 23 May 2010 12:38:45 +0000 (UTC)
commit 70efccac723cbee104b2ebb5ab6238da66b0ae1b
Author: Ruben Vermeersch <ruben savanne be>
Date: Thu Aug 13 20:41:45 2009 +0200
Remove a ton of unused stuff in PnmFile.
src/Imaging/PnmFile.cs | 161 ------------------------------------------------
1 files changed, 0 insertions(+), 161 deletions(-)
---
diff --git a/src/Imaging/PnmFile.cs b/src/Imaging/PnmFile.cs
index f68ffb3..cd9231c 100644
--- a/src/Imaging/PnmFile.cs
+++ b/src/Imaging/PnmFile.cs
@@ -92,110 +92,6 @@ namespace FSpot.Pnm {
return builder.ToString ();
}
- public static ushort [] ReadShort (Stream stream, int width, int height, int channels)
- {
- int length = width * height * channels;
- ushort [] data = new ushort [length];
- byte [] tmp = new byte [2];
-
- for (int i = 0; i < length; i++)
- {
- stream.Read (tmp, 0, tmp.Length);
- data [i] = BitConverter.ToUInt16 (tmp, 0, false);
- }
- return data;
- }
-
- static Gdk.Pixbuf LoadRGB16 (Stream stream, int width, int height)
- {
- Gdk.Pixbuf pixbuf = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, false, 8, width, height);
- unsafe {
- byte *pixels = (byte *)pixbuf.Pixels;
- int length = width * 6;
- byte [] buffer = new byte [length];
-
- for (int row = 0; row < height; row++) {
- stream.Read (buffer, 0, buffer.Length);
- for (int i = 0; i < width * 3; i++) {
- pixels [i] = (byte) (BitConverter.ToUInt16 (buffer, i * 2, false) >> 8);
- }
- pixels += pixbuf.Rowstride;
- }
- }
- return pixbuf;
- }
-
- static Gdk.Pixbuf LoadRGB8 (Stream stream, int width, int height)
- {
- Gdk.Pixbuf pixbuf = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, false, 8, width, height);
- unsafe {
- byte *pixels = (byte *)pixbuf.Pixels;
- byte [] buffer = new byte [width * 3];
-
- for (int i = 0; i < height; i++) {
- stream.Read (buffer, 0, buffer.Length);
-
- System.Runtime.InteropServices.Marshal.Copy (buffer, 0,
- (System.IntPtr)pixels, buffer.Length);
-
- pixels += pixbuf.Rowstride;
- }
- }
- return pixbuf;
- }
-
- static PixelBuffer LoadBufferRGB16 (Stream stream, int width, int height)
- {
- PixelBuffer pix = new UInt16Buffer (width, height);
- int count = width * 3;
- byte [] buffer = new byte [count * 2];
-
- for (int row = 0; row < height; row++) {
- int len = 0;
- while (len < buffer.Length) {
- int read = stream.Read (buffer, len, buffer.Length - len);
- if (read < 0)
- break;
- len += read;
- }
-
- pix.Fill16 (row, 0, buffer, 0, count, false);
- }
-
- return pix;
- }
-
- static PixelBuffer LoadBufferRGB8 (Stream stream, int width, int height)
- {
- PixelBuffer pix = new UInt16Buffer (width, height);
- int length = width * 3;
- byte [] buffer = new byte [length];
-
- for (int row = 0; row < height; row++) {
- stream.Read (buffer, 0, buffer.Length);
- pix.Fill8 (row, 0, buffer, 0, buffer.Length);
- }
-
- return pix;
- }
-
- public static FSpot.Imaging.PixelBuffer LoadBuffer (Stream stream)
- {
-
- Header header = new Header (stream);
- header.Dump ();
-
- switch (header.Magic) {
- case "P6":
- if (header.IsDeep)
- return LoadBufferRGB16 (stream, header.Width, header.Height);
- else
- return LoadBufferRGB8 (stream, header.Width, header.Height);
- default:
- throw new System.Exception (System.String.Format ("unknown pnm type {0}", header.Magic));
- }
- }
-
public void Save (Gdk.Pixbuf pixbuf, System.IO.Stream stream)
{
if (pixbuf.HasAlpha)
@@ -228,62 +124,5 @@ namespace FSpot.Pnm {
}
}
}
-
- public static Gdk.Pixbuf Load (Stream stream)
- {
- Header header = new Header (stream);
- header.Dump ();
-
- switch (header.Magic) {
- case "P6":
- if (header.IsDeep) {
-#if SKIP_BUFFER
- return LoadRGB16 (stream, header.Width, header.Height);
-#else
- stream.Position = 0;
- FSpot.Imaging.PixelBuffer image = FSpot.Pnm.PnmFile.LoadBuffer (stream);
- Gdk.Pixbuf result = image.ToPixbuf (Cms.Profile.CreateStandardRgb ());
- return result;
-#endif
- } else
- return LoadRGB8 (stream, header.Width, header.Height);
- default:
- throw new System.Exception (System.String.Format ("unknown pnm type {0}", header.Magic));
- }
- }
}
-
-#if ENABLE_NUNIT
- [TestFixture]
- public class Tests {
- [Test]
- 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);
- }
- }
- }
-#endif
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]