Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWade Berrier <wade@mono-cvs.ximian.com>2006-01-20 06:01:55 +0300
committerWade Berrier <wade@mono-cvs.ximian.com>2006-01-20 06:01:55 +0300
commit24906dde223bd634fe2b5ec231ba399eb01ed85e (patch)
tree41105c34861eec3b735807df22bb7b25baef78f9 /mcs/class/System.Drawing/Test/System.Drawing.Imaging
parentbf9916e270e2a7c449da248c0afcf667766e3fa2 (diff)
parent0694b14ef614fcbbd9b12a2b1a5ccd202fe7089a (diff)
oops, recopy from trunkmono-1-1-13-2
svn path=/branches/mono-1-1-13/mcs/; revision=55819
Diffstat (limited to 'mcs/class/System.Drawing/Test/System.Drawing.Imaging')
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Imaging/ChangeLog48
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestBmpCodec.cs159
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestColorMatrix.cs172
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageAttributes.cs103
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageCodecInfo.cs183
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageFormat.cs87
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestJpegCodec.cs133
-rwxr-xr-xmcs/class/System.Drawing/Test/System.Drawing.Imaging/tests-ms.sh28
-rwxr-xr-xmcs/class/System.Drawing/Test/System.Drawing.Imaging/tests.sh29
9 files changed, 942 insertions, 0 deletions
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/ChangeLog b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/ChangeLog
new file mode 100644
index 00000000000..75122b31a50
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/ChangeLog
@@ -0,0 +1,48 @@
+2005-11-13 Kornél Pál <kornelpal@hotmail.com>
+
+ * TestImageFormat.cs: Added ToStringTest.
+
+2005-10-31 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * TestImageFormat.cs: New test unit
+
+2005-09-16 Sebastien Pouliot <sebastien@ximian.com>
+
+ * TestBmpCodec.cs, TestColorMatrix.cs, TestImageAttributes.cs,
+ TestImageCodecInfo.cs, TestJpegCodec.cs: Deny UnmanagedCode permission
+ to all tests. This shows (when executed under MS runtime) that S.D API
+ is safe and doesn't requires high privileges to run - even if we know
+ that, deep down, this calls into GDI+.
+
+2005-08-19 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * TestBmpCodec.cs: Enable PixelFormat tests
+
+2005-08-16 Andrew Skiba <andrews@mainsoft.com>
+
+ * TestImageCodecInfo.cs: use regular expressions for results that may vary
+ while still in correct format, so same tests can be used for jvm
+
+2005-08-09 Andrew Skiba <andrews@mainsoft.com>
+
+ * TestImageCodecInfo.cs: FormatID, CodecName, DllName, FilenameExtension,
+ Flags, FormatDescription, MimeType properties checked
+
+2005-08-09 Andrew Skiba <andrews@mainsoft.com>
+
+ * TestImageCodecInfo.cs: refactor to make possible to add tests for all
+ properties, not only FormatID.
+
+2004-03-22 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * TestColorMatrix.cs: added test case
+ * TestImageAttributes.cs: added test case
+
+2004-06-10 Sanjay Gupta <gsanjay@novell.com>
+
+ * TestBmpCodec.cs, TestImageCodecInfo.cs, TestJpedCodec.cs: Removed
+ dependency on obsolete class, Assertion from NUnit.
+
+2004-03-17 Ravindra <rkumar@novell.com>
+ * Created this repository for System.Drawing.Imaging tests.
+ * ChangeLog: Added.
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestBmpCodec.cs b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestBmpCodec.cs
new file mode 100644
index 00000000000..dac4ffe1695
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestBmpCodec.cs
@@ -0,0 +1,159 @@
+//
+// BMPCodec class testing unit
+//
+// Author:
+//
+// Jordi Mas i Hernàndez (jordi@ximian.com)
+//
+// (C) 2004 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using NUnit.Framework;
+using System.IO;
+using System.Security.Cryptography;
+using System.Security.Permissions;
+using System.Text;
+
+namespace MonoTests.System.Drawing
+{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestBmpCodec
+ {
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady()
+ {
+
+ }
+
+ /* Get suffix to add to the filename */
+ internal string getOutSufix()
+ {
+ if (Environment.GetEnvironmentVariable("MSNet")==null)
+ return "-mono";
+
+ return "";
+ }
+
+ /* Get the input directory depending on the runtime*/
+ internal string getInFile(string file)
+ {
+ string sRslt, local;
+
+ local = "../System.Drawing/" + file;
+
+ sRslt = Path.GetFullPath (local);
+
+ if (File.Exists(sRslt)==false)
+ sRslt = "Test/System.Drawing/" + file;
+
+ return sRslt;
+ }
+
+ /* Checks bitmap features on a know 24-bits bitmap */
+ [Test]
+ public void Bitmap24bitFeatures()
+ {
+ string sInFile = getInFile ("bitmaps/almogaver24bits.bmp");
+ Bitmap bmp = new Bitmap(sInFile);
+ RectangleF rect;
+ GraphicsUnit unit = GraphicsUnit.World;
+
+ rect = bmp.GetBounds(ref unit);
+
+ Assert.AreEqual (PixelFormat.Format24bppRgb, bmp.PixelFormat);
+ Assert.AreEqual (173, bmp.Width);
+ Assert.AreEqual (183, bmp.Height);
+
+ Assert.AreEqual (0, rect.X);
+ Assert.AreEqual (0, rect.Y);
+ Assert.AreEqual (173, rect.Width);
+ Assert.AreEqual (183, rect.Height);
+
+ Assert.AreEqual (173, bmp.Size.Width);
+ Assert.AreEqual (183, bmp.Size.Height);
+ }
+
+
+
+ /* Checks bitmap features on a know 32-bits bitmap (codec)*/
+ [Test]
+ public void Bitmap32bitFeatures()
+ {
+ string sInFile = getInFile ("bitmaps/almogaver32bits.bmp");
+ Bitmap bmp = new Bitmap(sInFile);
+ RectangleF rect;
+ GraphicsUnit unit = GraphicsUnit.World;
+
+ rect = bmp.GetBounds(ref unit);
+
+ Assert.AreEqual (173, bmp.Width);
+ Assert.AreEqual (183, bmp.Height);
+
+ Assert.AreEqual (0, rect.X);
+ Assert.AreEqual (0, rect.Y);
+ Assert.AreEqual (173, rect.Width);
+ Assert.AreEqual (183, rect.Height);
+
+ Assert.AreEqual (173, bmp.Size.Width);
+ Assert.AreEqual (183, bmp.Size.Height);
+ }
+
+ [Test]
+ public void Save()
+ {
+ string sOutFile = "linerect" + getOutSufix() + ".bmp";
+
+ // Save
+ Bitmap bmp = new Bitmap(100,100, PixelFormat.Format32bppRgb);
+ Graphics gr = Graphics.FromImage(bmp);
+
+ Pen p = new Pen(Color.Red, 2);
+ gr.DrawLine(p, 10.0F, 10.0F, 90.0F, 90.0F);
+ gr.DrawRectangle(p, 10.0F, 10.0F, 80.0F, 80.0F);
+ p.Dispose();
+ bmp.Save(sOutFile, ImageFormat.Bmp);
+ gr.Dispose();
+ bmp.Dispose();
+
+ // Load
+ Bitmap bmpLoad = new Bitmap(sOutFile);
+
+ Color color = bmpLoad.GetPixel(10,10);
+
+ //Assert.AreEqual (Color.FromArgb(255,255,0,0), color);
+ }
+
+
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestColorMatrix.cs b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestColorMatrix.cs
new file mode 100644
index 00000000000..ceb64b45593
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestColorMatrix.cs
@@ -0,0 +1,172 @@
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//
+// Author:
+// Jordi Mas i Hernandez (jordi@ximian.com)
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using NUnit.Framework;
+using System.IO;
+using System.Security.Cryptography;
+using System.Security.Permissions;
+using System.Text;
+
+namespace MonoTests.System.Drawing
+{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestColorMatrix
+ {
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady()
+ {
+
+ }
+
+
+ [Test]
+ public void DefaultConstructor ()
+ {
+ ColorMatrix cm = new ColorMatrix ();
+
+ Assert.AreEqual (cm.Matrix00, 1);
+ Assert.AreEqual (cm.Matrix11, 1);
+ Assert.AreEqual (cm.Matrix22, 1);
+ Assert.AreEqual (cm.Matrix33, 1);
+ Assert.AreEqual (cm.Matrix44, 1);
+ Assert.AreEqual (cm.Matrix01, 0);
+ Assert.AreEqual (cm.Matrix02, 0);
+ Assert.AreEqual (cm.Matrix03, 0);
+ Assert.AreEqual (cm.Matrix04, 0);
+ Assert.AreEqual (cm.Matrix10, 0);
+ Assert.AreEqual (cm.Matrix12, 0);
+ Assert.AreEqual (cm.Matrix13, 0);
+ Assert.AreEqual (cm.Matrix14, 0);
+ Assert.AreEqual (cm.Matrix20, 0);
+ Assert.AreEqual (cm.Matrix21, 0);
+ Assert.AreEqual (cm.Matrix23, 0);
+ Assert.AreEqual (cm.Matrix24, 0);
+ Assert.AreEqual (cm.Matrix30, 0);
+ Assert.AreEqual (cm.Matrix31, 0);
+ Assert.AreEqual (cm.Matrix32, 0);
+ Assert.AreEqual (cm.Matrix34, 0);
+ Assert.AreEqual (cm.Matrix40, 0);
+ Assert.AreEqual (cm.Matrix41, 0);
+ Assert.AreEqual (cm.Matrix42, 0);
+ Assert.AreEqual (cm.Matrix43, 0);
+
+ }
+
+ [Test]
+ public void ConstructorArrayAndMethods ()
+ {
+ ColorMatrix cm = new ColorMatrix (new float[][] {
+ new float[] {0.393f, 0.349f, 0.272f, 0, 0},
+ new float[] {0.769f, 0.686f, 0.534f, 0, 0},
+ new float[] {0.189f, 0.168f, 0.131f, 0, 0},
+ new float[] { 0, 0, 0, 1, 0},
+ new float[] { 0, 0, 0, 0, 1}
+ });
+
+ Assert.AreEqual (cm.Matrix00, 0.393f);
+ Assert.AreEqual (cm.Matrix01, 0.349f);
+ Assert.AreEqual (cm.Matrix02, 0.272f);
+ Assert.AreEqual (cm.Matrix03, 0);
+ Assert.AreEqual (cm.Matrix04, 0);
+
+ Assert.AreEqual (cm.Matrix10, 0.769f);
+ Assert.AreEqual (cm.Matrix11, 0.686f);
+ Assert.AreEqual (cm.Matrix12, 0.534f);
+ Assert.AreEqual (cm.Matrix13, 0);
+ Assert.AreEqual (cm.Matrix14, 0);
+
+ Assert.AreEqual (cm.Matrix20, 0.189f);
+ Assert.AreEqual (cm.Matrix21, 0.168f);
+ Assert.AreEqual (cm.Matrix22, 0.131f);
+ Assert.AreEqual (cm.Matrix23, 0);
+ Assert.AreEqual (cm.Matrix24, 0);
+
+ Assert.AreEqual (cm.Matrix30, 0);
+ Assert.AreEqual (cm.Matrix31, 0);
+ Assert.AreEqual (cm.Matrix32, 0);
+ Assert.AreEqual (cm.Matrix33, 1);
+ Assert.AreEqual (cm.Matrix34, 0);
+
+ Assert.AreEqual (cm.Matrix40, 0);
+ Assert.AreEqual (cm.Matrix41, 0);
+ Assert.AreEqual (cm.Matrix42, 0);
+ Assert.AreEqual (cm.Matrix43, 0);
+ Assert.AreEqual (cm.Matrix44, 1);
+ }
+
+ [Test]
+ public void Property ()
+ {
+ ColorMatrix cm = new ColorMatrix (new float[][] {
+ new float[] {1, 0, 0, 0, 0},
+ new float[] {0.5f, 1, 0, 0, 0},
+ new float[] {0, 0.1f, 1.5f, 0, 0},
+ new float[] {0.5f, 3, 0.5f, 1, 0},
+ new float[] {0, 0, 0, 0, 0}
+ });
+
+ Assert.AreEqual (cm[0,0], 1);
+ Assert.AreEqual (cm[0,1], 0);
+ Assert.AreEqual (cm[0,2], 0);
+ Assert.AreEqual (cm[0,3], 0);
+ Assert.AreEqual (cm[0,4], 0);
+
+ Assert.AreEqual (cm[1,0], 0.5f);
+ Assert.AreEqual (cm[1,1], 1);
+ Assert.AreEqual (cm[1,2], 0);
+ Assert.AreEqual (cm[1,3], 0);
+ Assert.AreEqual (cm[1,4], 0);
+
+ Assert.AreEqual (cm[2,0], 0);
+ Assert.AreEqual (cm[2,1], 0.1f);
+ Assert.AreEqual (cm[2,2], 1.5f);
+ Assert.AreEqual (cm[2,3], 0);
+ Assert.AreEqual (cm[2,4], 0);
+
+ Assert.AreEqual (cm[3,0], 0.5f);
+ Assert.AreEqual (cm[3,1], 3);
+ Assert.AreEqual (cm[3,2], 0.5f);
+ Assert.AreEqual (cm[3,3], 1);
+ Assert.AreEqual (cm[3,4], 0);
+
+ Assert.AreEqual (cm[4,0], 0);
+ Assert.AreEqual (cm[4,1], 0);
+ Assert.AreEqual (cm[4,2], 0);
+ Assert.AreEqual (cm[4,3], 0);
+ Assert.AreEqual (cm[4,4], 0);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageAttributes.cs b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageAttributes.cs
new file mode 100644
index 00000000000..644458c6bb4
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageAttributes.cs
@@ -0,0 +1,103 @@
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//
+// Author:
+// Jordi Mas i Hernandez (jordi@ximian.com)
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using NUnit.Framework;
+using System.IO;
+using System.Security.Cryptography;
+using System.Security.Permissions;
+using System.Text;
+
+namespace MonoTests.System.Drawing
+{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestImageAttributes
+ {
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady()
+ {
+
+ }
+
+ private static Color ProcessColorMatrix (Color color, ColorMatrix colorMatrix)
+ {
+ Bitmap bmp = new Bitmap (64, 64);
+ Graphics gr = Graphics.FromImage (bmp);
+ ImageAttributes imageAttr = new ImageAttributes ();
+
+ bmp.SetPixel (0,0, color);
+
+ imageAttr.SetColorMatrix (colorMatrix);
+ gr.DrawImage (bmp, new Rectangle (0, 0, 64,64), 0,0, 64,64, GraphicsUnit.Pixel, imageAttr);
+ return bmp.GetPixel (0,0);
+ }
+
+
+ // Text Color Matrix processing
+ [Test]
+ public void ColorMatrix ()
+ {
+ Color clr_src, clr_rslt;
+
+ ColorMatrix cm = new ColorMatrix (new float[][] {
+ new float[] {2, 0, 0, 0, 0}, //R
+ new float[] {0, 1, 0, 0, 0}, //G
+ new float[] {0, 0, 1, 0, 0}, //B
+ new float[] {0, 0, 0, 1, 0}, //A
+ new float[] {0.2f, 0, 0, 0, 0}, //Translation
+ });
+
+ clr_src = Color.FromArgb (255, 100, 20, 50);
+ clr_rslt = ProcessColorMatrix (clr_src, cm);
+
+ Assert.AreEqual (clr_rslt, Color.FromArgb (255, 251, 20, 50));
+
+
+ cm = new ColorMatrix (new float[][] {
+ new float[] {1, 0, 0, 0, 0}, //R
+ new float[] {0, 1, 0, 0, 0}, //G
+ new float[] {0, 0, 1.5f, 0, 0}, //B
+ new float[] {0, 0, 0.5f, 1, 0}, //A
+ new float[] {0, 0, 0, 0, 0}, //Translation
+ });
+
+ clr_src = Color.FromArgb (255, 100, 40, 25);
+ clr_rslt = ProcessColorMatrix (clr_src, cm);
+ Assert.AreEqual (clr_rslt, Color.FromArgb (255, 100, 40, 165));
+ }
+
+
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageCodecInfo.cs b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageCodecInfo.cs
new file mode 100644
index 00000000000..39ef67ef733
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageCodecInfo.cs
@@ -0,0 +1,183 @@
+//
+// ImageCodecInfo class testing unit
+//
+// Author:
+//
+// Jordi Mas i Hernàndez (jordi@ximian.com)
+//
+// (C) 2004 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using NUnit.Framework;
+using System.Collections;
+using System.Security.Permissions;
+using System.Text.RegularExpressions;
+
+namespace MonoTests.System.Drawing
+{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestImageCodecInfo
+ {
+ Hashtable decoders;
+ Hashtable encoders;
+
+ ImageCodecInfo GetEncoder (Guid clsid)
+ {
+ return (ImageCodecInfo) encoders [clsid];
+ }
+
+ ImageCodecInfo GetDecoder (Guid clsid) {
+ return (ImageCodecInfo) decoders [clsid];
+ }
+
+ [TestFixtureSetUp]
+ public void FixtureGetReady()
+ {
+ ImageCodecInfo [] arrEnc = ImageCodecInfo.GetImageDecoders ();
+ ImageCodecInfo [] arrDec = ImageCodecInfo.GetImageEncoders ();
+ decoders = new Hashtable ();
+ encoders = new Hashtable ();
+
+ foreach (ImageCodecInfo decoder in arrDec)
+ decoders[decoder.Clsid] = decoder;
+
+ foreach (ImageCodecInfo encoder in arrEnc)
+ encoders[encoder.Clsid] = encoder;
+ }
+
+ static void Check (ImageCodecInfo e, ImageCodecInfo d, Guid FormatID, string CodecName, string DllName,
+ string FilenameExtension, ImageCodecFlags Flags, string FormatDescription,
+ string MimeType, int Version)
+ {
+ Regex extRegex = new Regex (@"^(\*\.\w+(;(\*\.\w+))*;)?"+
+ Regex.Escape (FilenameExtension)+@"(;\*\.\w+(;(\*\.\w+))*)?$",
+ RegexOptions.IgnoreCase | RegexOptions.Singleline);
+
+ if (e != null) {
+ Assert.AreEqual (FormatID, e.FormatID, "Encoder.FormatID");
+ Assert.IsTrue (e.CodecName.IndexOf (CodecName)>=0,
+ "Encoder.CodecName contains "+CodecName);
+ Assert.AreEqual (DllName, e.DllName, "Encoder.DllName");
+ Assert.IsTrue (extRegex.IsMatch (e.FilenameExtension),
+ "Encoder.FilenameExtension is a right list with "+FilenameExtension);
+ Assert.AreEqual (Flags, e.Flags, "Encoder.Flags");
+ Assert.IsTrue (e.FormatDescription.IndexOf (FormatDescription)>=0,
+ "Encoder.FormatDescription contains "+FormatDescription);
+ Assert.IsTrue (e.MimeType.IndexOf (MimeType)>=0,
+ "Encoder.MimeType contains "+MimeType);
+ }
+ if (d != null) {
+ Assert.AreEqual (FormatID, d.FormatID, "Decoder.FormatID");
+ Assert.IsTrue (d.CodecName.IndexOf (CodecName)>=0,
+ "Decoder.CodecName contains "+CodecName);
+ Assert.AreEqual (DllName, d.DllName, "Decoder.DllName");
+ Assert.IsTrue (extRegex.IsMatch (d.FilenameExtension),
+ "Decoder.FilenameExtension is a right list with "+FilenameExtension);
+ Assert.AreEqual (Flags, d.Flags, "Decoder.Flags");
+ Assert.IsTrue (d.FormatDescription.IndexOf (FormatDescription)>=0,
+ "Decoder.FormatDescription contains "+FormatDescription);
+ Assert.IsTrue (d.MimeType.IndexOf (MimeType)>=0,
+ "Decoder.MimeType contains "+MimeType);
+ }
+ /*
+ if (SignatureMasks == null) {
+ Assert.AreEqual (null, e.SignatureMasks, "Encoder.SignatureMasks");
+ Assert.AreEqual (null, d.SignatureMasks, "Decoder.SignatureMasks");
+ }
+ else {
+ Assert.AreEqual (SignatureMasks.Length, e.SignatureMasks.Length, "Encoder.SignatureMasks.Length");
+ Assert.AreEqual (SignatureMasks.Length, d.SignatureMasks.Length, "Decoder.SignatureMasks.Length");
+ for (int i = 0; i < SignatureMasks.Length; i++) {
+ Assert.AreEqual (SignatureMasks[i].Length, e.SignatureMasks[i].Length,
+ "Encoder.SignatureMasks["+i.ToString ()+"].Length");
+ Assert.AreEqual (SignatureMasks[i].Length, d.SignatureMasks[i].Length,
+ "Decoder.SignatureMasks["+i.ToString ()+"].Length");
+ for (int j = 0; j < SignatureMasks[i].Length; j++) {
+ Assert.AreEqual (SignatureMasks[i][j], e.SignatureMasks[i][j],
+ "Encoder.SignatureMasks["+i.ToString ()+"]["+j.ToString ()+"]");
+ Assert.AreEqual (SignatureMasks[i][j], d.SignatureMasks[i][j],
+ "Decoder.SignatureMasks["+i.ToString ()+"]["+j.ToString ()+"]");
+ }
+ }
+ }
+ */
+
+ }
+
+ [Test]
+ public void BMPCodec()
+ {
+ Guid g = new Guid ("557cf400-1a04-11d3-9a73-0000f81ef32e");
+ Check (GetEncoder (g), GetDecoder (g), ImageFormat.Bmp.Guid,
+ "BMP", null, "*.BMP",
+ ImageCodecFlags.Builtin|ImageCodecFlags.Encoder|ImageCodecFlags.Decoder|ImageCodecFlags.SupportBitmap,
+ "BMP", "image/bmp", 1);
+ }
+
+ [Test]
+ public void GifCodec()
+ {
+ Guid g = new Guid ("557cf402-1a04-11d3-9a73-0000f81ef32e");
+ Check (GetEncoder (g), GetDecoder (g), ImageFormat.Gif.Guid,
+ "GIF", null, "*.GIF",
+ ImageCodecFlags.Builtin|ImageCodecFlags.Encoder|ImageCodecFlags.Decoder|ImageCodecFlags.SupportBitmap,
+ "GIF", "image/gif", 1);
+ }
+
+ [Test]
+ public void JpegCodec()
+ {
+ Guid g = new Guid ("557cf401-1a04-11d3-9a73-0000f81ef32e");
+ Check (GetEncoder (g), GetDecoder (g), ImageFormat.Jpeg.Guid,
+ "JPEG", null, "*.JPG",
+ ImageCodecFlags.Builtin|ImageCodecFlags.Encoder|ImageCodecFlags.Decoder|ImageCodecFlags.SupportBitmap,
+ "JPEG", "image/jpeg", 1);
+ }
+
+ [Test]
+ public void PngCodec()
+ {
+ Guid g = new Guid ("557cf406-1a04-11d3-9a73-0000f81ef32e");
+ Check (GetEncoder (g), GetDecoder (g), ImageFormat.Png.Guid,
+ "PNG", null, "*.PNG",
+ ImageCodecFlags.Builtin|ImageCodecFlags.Encoder|ImageCodecFlags.Decoder|ImageCodecFlags.SupportBitmap,
+ "PNG", "image/png", 1);
+ }
+ [Test]
+ public void IconCodec() {
+ Guid g = new Guid ("557cf407-1a04-11d3-9a73-0000f81ef32e");
+ Check (null, GetDecoder (g), ImageFormat.Bmp.Guid,
+ "ICO", null, "*.ICO",
+ ImageCodecFlags.Builtin|ImageCodecFlags.Encoder|ImageCodecFlags.SupportBitmap,
+ "ICO", "image/x-icon", 1);
+ }
+
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageFormat.cs b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageFormat.cs
new file mode 100644
index 00000000000..f83bed886a9
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageFormat.cs
@@ -0,0 +1,87 @@
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Author:
+//
+// Jordi Mas i Hernàndez (jordi@ximian.com)
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using NUnit.Framework;
+using System.IO;
+using System.Security.Cryptography;
+using System.Security.Permissions;
+using System.Text;
+
+namespace MonoTests.System.Drawing
+{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestImageFormat
+ {
+ private static ImageFormat BmpImageFormat = new ImageFormat (new Guid ("b96b3cab-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat EmfImageFormat = new ImageFormat (new Guid ("b96b3cac-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat ExifImageFormat = new ImageFormat (new Guid ("b96b3cb2-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat GifImageFormat = new ImageFormat (new Guid ("b96b3cb0-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat TiffImageFormat = new ImageFormat (new Guid ("b96b3cb1-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat PngImageFormat = new ImageFormat(new Guid("b96b3caf-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat MemoryBmpImageFormat = new ImageFormat (new Guid ("b96b3caa-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat IconImageFormat = new ImageFormat (new Guid ("b96b3cb5-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat JpegImageFormat = new ImageFormat(new Guid("b96b3cae-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat WmfImageFormat = new ImageFormat (new Guid ("b96b3cad-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat CustomImageFormat = new ImageFormat (new Guid ("48749428-316f-496a-ab30-c819a92b3137"));
+
+ [Test]
+ public void DefaultImageFormats ()
+ {
+ Assert.AreEqual (BmpImageFormat.Guid, ImageFormat.Bmp.Guid, "DefaultImageFormats#1");
+ Assert.AreEqual (EmfImageFormat.Guid, ImageFormat.Emf.Guid, "DefaultImageFormats#2");
+ Assert.AreEqual (ExifImageFormat.Guid, ImageFormat.Exif.Guid, "DefaultImageFormats#3");
+ Assert.AreEqual (GifImageFormat.Guid, ImageFormat.Gif.Guid, "DefaultImageFormats#4");
+ Assert.AreEqual (TiffImageFormat.Guid, ImageFormat.Tiff.Guid, "DefaultImageFormats#5");
+ Assert.AreEqual (PngImageFormat.Guid, ImageFormat.Png.Guid, "DefaultImageFormats#6");
+ Assert.AreEqual (MemoryBmpImageFormat.Guid, ImageFormat.MemoryBmp.Guid, "DefaultImageFormats#7");
+ Assert.AreEqual (IconImageFormat.Guid, ImageFormat.Icon.Guid, "DefaultImageFormats#8");
+ Assert.AreEqual (JpegImageFormat.Guid, ImageFormat.Jpeg.Guid, "DefaultImageFormats#9");
+ Assert.AreEqual (WmfImageFormat.Guid, ImageFormat.Wmf.Guid, "DefaultImageFormats#10");
+ }
+
+ [Test]
+ public void ToStringTest ()
+ {
+ Assert.AreEqual (BmpImageFormat.ToString (), "Bmp", "ToStringTest#1");
+ Assert.AreEqual (EmfImageFormat.ToString (), "Emf", "ToStringTest#2");
+ Assert.AreEqual (ExifImageFormat.ToString (), "Exif", "ToStringTest#3");
+ Assert.AreEqual (GifImageFormat.ToString (), "Gif", "ToStringTest#4");
+ Assert.AreEqual (TiffImageFormat.ToString (), "Tiff", "ToStringTest#5");
+ Assert.AreEqual (PngImageFormat.ToString (), "Png", "ToStringTest#6");
+ Assert.AreEqual (MemoryBmpImageFormat.ToString (), "MemoryBmp", "ToStringTest#7");
+ Assert.AreEqual (IconImageFormat.ToString (), "Icon", "ToStringTest#8");
+ Assert.AreEqual (JpegImageFormat.ToString (), "Jpeg", "ToStringTest#9");
+ Assert.AreEqual (WmfImageFormat.ToString (), "Wmf", "ToStringTest#10");
+ Assert.AreEqual (CustomImageFormat.ToString (), "[ImageFormat: 48749428-316f-496a-ab30-c819a92b3137]", "ToStringTest#11");
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestJpegCodec.cs b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestJpegCodec.cs
new file mode 100644
index 00000000000..54aaa327b4b
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestJpegCodec.cs
@@ -0,0 +1,133 @@
+//
+// JpegCodec class testing unit
+//
+// Author:
+//
+// Jordi Mas i Hernàndez (jordi@ximian.com)
+//
+// (C) 2004 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using NUnit.Framework;
+using System.IO;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing
+{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestJpegCodec
+ {
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady()
+ {
+
+ }
+
+ /* Get suffix to add to the filename */
+ internal string getOutSufix()
+ {
+ if (Environment.GetEnvironmentVariable("MSNet")==null)
+ return "-mono";
+
+ return "";
+ }
+
+ /* Get the input directory depending on the runtime*/
+ internal string getInFile(string file)
+ {
+ string sRslt, local;
+
+ local = "../System.Drawing/" + file;
+
+ sRslt = Path.GetFullPath (local);
+
+ if (File.Exists(sRslt)==false)
+ sRslt = "Test/System.Drawing/" + file;
+
+ return sRslt;
+ }
+
+ /* Checks bitmap features on a know 24-bits bitmap */
+ //[Test]
+ public void Bitmap24bitFeatures()
+ {
+ string sInFile = getInFile ("bitmaps/nature24bits.jpg");
+ Bitmap bmp = new Bitmap(sInFile);
+ RectangleF rect;
+ GraphicsUnit unit = GraphicsUnit.World;
+
+ rect = bmp.GetBounds(ref unit);
+
+ Assert.AreEqual (PixelFormat.Format24bppRgb, bmp.PixelFormat);
+ Assert.AreEqual (110, bmp.Width);
+ Assert.AreEqual (100, bmp.Height);
+
+ Assert.AreEqual (0, rect.X);
+ Assert.AreEqual (0, rect.Y);
+ Assert.AreEqual (110, rect.Width);
+ Assert.AreEqual (100, rect.Height);
+
+ Assert.AreEqual (110, bmp.Size.Width);
+ Assert.AreEqual (100, bmp.Size.Height);
+
+ }
+
+ //[Test]
+ public void Save()
+ {
+ string sOutFile = "linerect" + getOutSufix() + ".jpeg";
+
+ // Save
+ Bitmap bmp = new Bitmap(100,100, PixelFormat.Format32bppRgb);
+ Graphics gr = Graphics.FromImage(bmp);
+
+ Pen p = new Pen(Color.Red, 2);
+ gr.DrawLine(p, 10.0F, 10.0F, 90.0F, 90.0F);
+ gr.DrawRectangle(p, 10.0F, 10.0F, 80.0F, 80.0F);
+ p.Dispose();
+ bmp.Save(sOutFile, ImageFormat.Bmp);
+ gr.Dispose();
+ bmp.Dispose();
+
+ // Load
+ Bitmap bmpLoad = new Bitmap(sOutFile);
+
+ Color color = bmpLoad.GetPixel(10,10);
+
+ //Assert.AreEqual (Color.FromArgb(255,255,0,0), color);
+ }
+
+
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests-ms.sh b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests-ms.sh
new file mode 100755
index 00000000000..98b2c00dbe8
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests-ms.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+if [ $# -eq 0 ]; then
+ echo "You should give a list of test names such as: "
+ echo "$0 System.Drawing.TestStringFormat"
+ echo "or"
+ echo "$0 all"
+ exit 1
+fi
+
+export MSNet=Yes
+cp ../../System.Drawing_test.dll .
+topdir=../../../..
+NUNITCONSOLE=$topdir/class/lib/nunit-console.exe
+MONO_PATH=$topdir/nunit20:$topdir/class/lib:.
+
+for i in $@; do
+ if [ "$i" = "all" ]; then
+ fixture=""
+ else
+ fixture="/fixture:MonoTests.${i}"
+ fi
+ MONO_PATH=$MONO_PATH \
+ ${NUNITCONSOLE} System.Drawing_test.dll $fixture
+done
+
+
+
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests.sh b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests.sh
new file mode 100755
index 00000000000..511cfcd6ee6
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+if [ $# -eq 0 ]; then
+ echo "You should give a list of test names such as: "
+ echo "$0 System.Drawing.TestStringFormat"
+ echo "or"
+ echo "$0 all"
+ exit 1
+fi
+
+cp ../../System.Drawing_test_default.dll .
+
+topdir=../../../..
+NUNITCONSOLE=$topdir/class/lib/default/nunit-console.exe
+MONO_PATH=$topdir/nunit20:$topdir/class/lib/default:.
+
+
+for i in $@; do
+ if [ "$i" = "all" ]; then
+ fixture=""
+ else
+ fixture="/fixture:MonoTests.${i}"
+ fi
+ MONO_PATH=$MONO_PATH \
+ mono --debug ${NUNITCONSOLE} System.Drawing_test_default.dll $fixture
+done
+
+
+