Răsfoiți Sursa

2007-04-10 Sebastien Pouliot <[email protected]>
* GifCodecTest.cs: Fix Save* test cases to check 8bpp indexed for all
GIF saved. Added comments to why we're not getting the "right" Red.

svn path=/trunk/mcs/; revision=75591

Sebastien Pouliot 19 ani în urmă
părinte
comite
f9c8a4fa7f

+ 3 - 1
mcs/class/System.Drawing/Test/System.Drawing.Imaging/ChangeLog

@@ -1,5 +1,7 @@
-2007-04-10  Sebastien Pouliot  <[email protected]>
+2007-04-10  Sebastien Pouliot  <[email protected]> 
 
+	* GifCodecTest.cs: Fix Save* test cases to check 8bpp indexed for all
+	GIF saved. Added comments to why we're not getting the "right" Red.
 	* TestBmpCodec.cs: Remove "NotWorking" from Bitmap32bitPixels test 
 	case. The file is a 32bpp RGB (no alpha).
 

+ 22 - 19
mcs/class/System.Drawing/Test/System.Drawing.Imaging/GifCodecTest.cs

@@ -210,7 +210,7 @@ namespace MonoTests.System.Drawing.Imaging {
 			}
 		}
 
-		private void Save (PixelFormat original, PixelFormat expected, bool colorCheck)
+		private void Save (PixelFormat original, PixelFormat expected, bool exactColorCheck)
 		{
 			string sOutFile = String.Format ("linerect{0}-{1}.gif", getOutSufix (), expected.ToString ());
 
@@ -224,15 +224,22 @@ namespace MonoTests.System.Drawing.Imaging {
 			}
 
 			try {
-// FIXME: we don't save a pure red (F8 instead of FF) into the file so the color-check assert will fail
 				bmp.Save (sOutFile, ImageFormat.Gif);
 
 				// Load
 				using (Bitmap bmpLoad = new Bitmap (sOutFile)) {
-					Assert.AreEqual (expected, bmp.PixelFormat, "PixelFormat");
-					if (colorCheck) {
-						Color color = bmpLoad.GetPixel (10, 10);
+					Assert.AreEqual (expected, bmpLoad.PixelFormat, "PixelFormat");
+					Color color = bmpLoad.GetPixel (10, 10);
+					if (exactColorCheck) {
 						Assert.AreEqual (Color.FromArgb (255, 255, 0, 0), color, "Red");
+					} else {
+// FIXME: we don't save a pure red (F8 instead of FF) into the file so the color-check assert will fail
+// this is due to libgif's QuantizeBuffer. An alternative would be to make our own that checks if less than 256 colors
+// are used in the bitmap (or else use QuantizeBuffer).
+						Assert.AreEqual (255, color.A, "A");
+						Assert.IsTrue (color.R >= 248, "R");
+						Assert.AreEqual (0, color.G, "G");
+						Assert.AreEqual (0, color.B, "B");
 					}
 				}
 			}
@@ -248,52 +255,48 @@ namespace MonoTests.System.Drawing.Imaging {
 		}
 
 		[Test]
-		[Category ("NotWorking")] // palette mismatch
 		public void Save_24bppRgb ()
 		{
-			Save (PixelFormat.Format24bppRgb, PixelFormat.Format24bppRgb, true);
+			Save (PixelFormat.Format24bppRgb, PixelFormat.Format8bppIndexed, false);
 		}
 
 		[Test]
-		[Category ("NotWorking")] // palette mismatch
 		public void Save_32bppRgb ()
 		{
-			Save (PixelFormat.Format32bppRgb, PixelFormat.Format32bppRgb, true);
+			Save (PixelFormat.Format32bppRgb, PixelFormat.Format8bppIndexed, false);
 		}
 
 		[Test]
-		[Category ("NotWorking")] // palette mismatch
 		public void Save_32bppArgb ()
 		{
-			Save (PixelFormat.Format32bppArgb, PixelFormat.Format32bppArgb, true);
+			Save (PixelFormat.Format32bppArgb, PixelFormat.Format8bppIndexed, false);
 		}
 
 		[Test]
-		[Category ("NotWorking")] // palette mismatch
 		public void Save_32bppPArgb ()
 		{
-			Save (PixelFormat.Format32bppPArgb, PixelFormat.Format32bppPArgb, true);
+			Save (PixelFormat.Format32bppPArgb, PixelFormat.Format8bppIndexed, false);
 		}
 
 		[Test]
-		[Category ("NotWorking")]
+		[Category ("NotWorking")] // libgdiplus/cairo can't create a bitmap with this format
 		public void Save_48bppRgb ()
 		{
-			Save (PixelFormat.Format48bppRgb, PixelFormat.Format48bppRgb, false);
+			Save (PixelFormat.Format48bppRgb, PixelFormat.Format8bppIndexed, false);
 		}
 
 		[Test]
-		[Category ("NotWorking")]
+		[Category ("NotWorking")] // libgdiplus/cairo can't create a bitmap with this format
 		public void Save_64bppArgb ()
 		{
-			Save (PixelFormat.Format64bppArgb, PixelFormat.Format64bppArgb, false);
+			Save (PixelFormat.Format64bppArgb, PixelFormat.Format8bppIndexed, false);
 		}
 
 		[Test]
-		[Category ("NotWorking")]
+		[Category ("NotWorking")] // libgdiplus/cairo can't create a bitmap with this format
 		public void Save_64bppPArgb ()
 		{
-			Save (PixelFormat.Format64bppPArgb, PixelFormat.Format64bppPArgb, false);
+			Save (PixelFormat.Format64bppPArgb, PixelFormat.Format8bppIndexed, false);
 		}
 	}
 }