2007-04-16 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / class / System.Drawing / Test / System.Drawing / GDIPlusTest.cs
index a011dd75a44b95db8c0a48327fab4a00fa301d4c..43e96abc38bd209d3f67569f99ebbe2d8fa9950c 100644 (file)
@@ -144,6 +144,41 @@ namespace MonoTests.System.Drawing {
                        Assert.AreEqual (Status.InvalidParameter, GDIPlus.GdipCreateBitmapFromScan0 (-1, 10, 10, PixelFormat.Format32bppArgb, IntPtr.Zero, out bmp), "negative width");
                }
 
+               [Test]
+               public void Format1bppIndexed_GetSetPixel ()
+               {
+                       IntPtr bmp;
+                       Assert.AreEqual (Status.Ok, GDIPlus.GdipCreateBitmapFromScan0 (10, 10, 0, PixelFormat.Format1bppIndexed, IntPtr.Zero, out bmp), "GdipCreateBitmapFromScan0");
+                       Assert.IsTrue (bmp != IntPtr.Zero, "bmp");
+                       try {
+                               int argb;
+                               Assert.AreEqual (Status.Ok, GDIPlus.GdipBitmapGetPixel (bmp, 0, 0, out argb), "GdipBitmapGetPixel");
+                               Assert.AreEqual (-16777216, argb, "argb");
+                               Assert.AreEqual (Status.InvalidParameter, GDIPlus.GdipBitmapSetPixel (bmp, 0, 0, argb), "GdipBitmapSetPixel");
+                       }
+                       finally {
+                               Assert.AreEqual (Status.Ok, GDIPlus.GdipDisposeImage (bmp), "GdipDisposeImage");
+                       }
+               }
+
+               [Test]
+               [Category ("NotWorking")] // libgdiplus doesn't support this format
+               public void Format16bppGrayScale_GetSetPixel ()
+               {
+                       IntPtr bmp;
+                       Assert.AreEqual (Status.Ok, GDIPlus.GdipCreateBitmapFromScan0 (10, 10, 0, PixelFormat.Format16bppGrayScale, IntPtr.Zero, out bmp), "GdipCreateBitmapFromScan0");
+                       Assert.IsTrue (bmp != IntPtr.Zero, "bmp");
+                       try {
+                               int argb = 0;
+                               // and MS GDI+ can get or set pixels on it
+                               Assert.AreEqual (Status.InvalidParameter, GDIPlus.GdipBitmapGetPixel (bmp, 0, 0, out argb), "GdipBitmapGetPixel");
+                               Assert.AreEqual (Status.InvalidParameter, GDIPlus.GdipBitmapSetPixel (bmp, 0, 0, argb), "GdipBitmapSetPixel");
+                       }
+                       finally {
+                               Assert.AreEqual (Status.Ok, GDIPlus.GdipDisposeImage (bmp), "GdipDisposeImage");
+                       }
+               }
+
                [Test]
                public void Unlock ()
                {