public void ReadAndSaveBitmapsTest() { ExtBitmap.ExtBitmap.SetHWndProvider(null); ExtBitmap.ExtBitmap2.SetHWndProvider(null); ExtBitmap.ExtBitmap3.SetHWndProvider(null); FastFind.FastFindHelper.SetHWndProvider(null); ExtBitmap.ExtBitmap eb1 = new ExtBitmap.ExtBitmap(); ExtBitmap.ExtBitmap2 eb2 = new ExtBitmap.ExtBitmap2(); ExtBitmap.ExtBitmap3 eb3 = new ExtBitmap.ExtBitmap3(); using (Chrono chrono = new Chrono("Screen capture with ExtBitmap in Background mode")) { chrono.Success = eb1.SnapShot(false); Assert.IsTrue(chrono.Success == true, "ExtBitmap screen capture"); if (chrono.Success == true) { chrono.Comment = string.Format("Size {0}x{1}", eb1.Width, eb1.Height); } } using (Chrono chrono = new Chrono("Screen capture with ExtBitmap2 in Background mode")) { chrono.Success = eb2.SnapShot(false); Assert.IsTrue(chrono.Success == true, "ExtBitmap2 screen capture"); if (chrono.Success == true) { chrono.Comment = string.Format("Size {0}x{1}", eb2.Width, eb2.Height); } } using (Chrono chrono = new Chrono("Screen capture with ExtBitmap3 in Background mode")) { chrono.Success = eb3.SnapShot(false); Assert.IsTrue(chrono.Success == true, "ExtBitmap3 screen capture"); if (chrono.Success == true) { chrono.Comment = string.Format("Size {0}x{1}", eb3.Width, eb3.Height); } } using (Chrono chrono = new Chrono("Screen capture with FastFind")) { chrono.Success = FastFindHelper.TakeFullScreenCapture(true); Assert.IsTrue(chrono.Success == true, "FastFind screen capture"); if (chrono.Success == true) { chrono.Comment = string.Format("Size {0}x{1}", eb3.Width, eb3.Height); } } eb1.Save("eb1.png"); eb2.Save("eb2.png"); eb3.Save("eb3.png"); FastFindWrapper.SaveBMP(FastFindHelper.DEFAULT_SNAP, "ff"); //FastFindWrapper.SaveJPG(FastFindHelper.DEFAULT_SNAP, "ff", 100); FastFindWrapper.LoadFromFile(FastFindHelper.DEFAULT_SNAP, FastFindWrapper.LastSavedFileName); eb1.LoadFromFile(FastFindWrapper.LastSavedFileName); eb2.LoadFromFile(FastFindWrapper.LastSavedFileName); eb3.LoadFromFile(FastFindWrapper.LastSavedFileName); // Makes sure that all 4 bitmaps returns the same pixel color for an arbitrary pixel Assert.AreEqual(eb1.NativeGetPixel(150, 150).ToArgb() & 0x00FFFFFF, eb1.GetPixel(150, 150) & 0x00FFFFFF); Assert.AreEqual(eb2.NativeGetPixel(150, 150).ToArgb() & 0x00FFFFFF, eb2.GetPixel(150, 150) & 0x00FFFFFF); Assert.AreEqual(eb3.NativeGetPixel(150, 150).ToArgb() & 0x00FFFFFF, eb3.GetPixel(150, 150) & 0x00FFFFFF); Assert.AreEqual(eb1.GetPixel(150, 150), eb2.GetPixel(150, 150)); Assert.AreEqual(eb2.GetPixel(150, 150), eb3.GetPixel(150, 150)); Assert.AreEqual(FastFindWrapper.GetPixel(150, 150, FastFindHelper.DEFAULT_SNAP), eb1.GetPixel(150, 150)); int clr = FastFindWrapper.GetPixel(150, 150, FastFindHelper.DEFAULT_SNAP); // Makes sure that all 4 bitmaps have the same colour count with shade variation Assert.AreEqual(FastFindWrapper.ColorCount(clr, FastFindHelper.DEFAULT_SNAP, 20), eb1.CountPixels(clr, 20, true)); Assert.AreEqual(eb1.CountPixels(clr, 20, true), eb2.CountPixels(clr, 20, true)); Assert.AreEqual(eb2.CountPixels(clr, 20, true), eb3.CountPixels(clr, 20, true)); }