// Jonathan Gilbert <logic@deltaq.org>
//
// (C) 2004 Ximian, Inc. http://www.ximian.com
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004,2006 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
[SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
public class TestBitmap {
- [TearDown]
- public void Clean() {}
-
- [SetUp]
- public void GetReady()
- {
-
- }
-
[Test]
public void TestPixels()
{
return sRslt;
}
-
+
+ // note: this test fails when saving (for the same reason) on Mono and MS.NET
//[Test]
public void MakeTransparent()
{
public void Clone()
{
string sInFile = getInFile ("bitmaps/almogaver24bits.bmp");
- string sOutFile = getOutSubDir() + "clone24.bmp";
-
Rectangle rect = new Rectangle(0,0,50,50);
Bitmap bmp = new Bitmap(sInFile);
Bitmap bmpNew = bmp.Clone (rect, PixelFormat.Format32bppArgb);
-
Color colororg0 = bmp.GetPixel(0,0);
Color colororg50 = bmp.GetPixel(49,49);
Color colornew0 = bmpNew.GetPixel(0,0);
public string RotateBmp (Bitmap src, RotateFlipType rotate)
{
- int witdh = 150, height = 150, index = 0;
- byte[] pixels = new byte [witdh * height * 3];
+ int width = 150, height = 150, index = 0;
+ byte[] pixels = new byte [width * height * 3];
Bitmap bmp_rotate;
byte[] hash;
Color clr;
-
- bmp_rotate = src.Clone (new RectangleF (0,0, witdh, height), PixelFormat.Format32bppArgb);
+ bmp_rotate = src.Clone (new RectangleF (0,0, width, height), PixelFormat.Format32bppArgb);
bmp_rotate.RotateFlip (rotate);
for (int y = 0; y < height; y++) {
- for (int x = 0; x < witdh; x++) {
+ for (int x = 0; x < width; x++) {
clr = bmp_rotate.GetPixel (x,y);
pixels[index++] = clr.R; pixels[index++] = clr.G; pixels[index++] = clr.B;
}
public void Rotate()
{
string sInFile = getInFile ("bitmaps/almogaver24bits.bmp");
- Bitmap bmp = new Bitmap(sInFile);
+ Bitmap bmp = new Bitmap(sInFile);
Assert.AreEqual ("312958A3C67402E1299413794988A3", RotateBmp (bmp, RotateFlipType.Rotate90FlipNone));
Assert.AreEqual ("BF70D8DA4F1545AEDD77D0296B47AE", RotateBmp (bmp, RotateFlipType.Rotate180FlipNone));
resulting pixels using MD5
*/
[Test]
+ [Category ("NotDotNet")] // that doesn't work under MS.NET and Windows (even without the StreamWriter)
public void Rotate1bit4bit()
{
string[] files = {
firsts, changes them, and then using GetPixel does another check of the changes.
The results match the .Net framework
*/
- //[Test]
+ [Test]
+ [Category ("NotWorking")]
public void LockBitmap ()
{
string hash = "";
}
}
#endif
+ [Test]
+ public void DefaultFormat1 ()
+ {
+ using (Bitmap bmp = new Bitmap (20, 20)) {
+ Assert.AreEqual (ImageFormat.MemoryBmp, bmp.RawFormat);
+ }
+ }
+
+ [Test]
+ public void DefaultFormat2 ()
+ {
+ string filename = Path.GetTempFileName ();
+ using (Bitmap bmp = new Bitmap (20, 20)) {
+ bmp.Save (filename);
+ }
+
+ using (Bitmap other = new Bitmap (filename)) {
+ Assert.AreEqual (ImageFormat.Png, other.RawFormat);
+ }
+ File.Delete (filename);
+ }
+
+ [Test]
+ public void BmpDataStride1 ()
+ {
+ Bitmap bmp = new Bitmap (184, 184, PixelFormat.Format1bppIndexed);
+ BitmapData data = bmp.LockBits (new Rectangle (0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format1bppIndexed);
+ try {
+ Assert.AreEqual (24, data.Stride);
+ } finally {
+ bmp.UnlockBits (data);
+ bmp.Dispose ();
+ }
+ }
}
}
+