Accord.Imaging.Tests.UnmanagedImageTest.ToManagedImageTest C# (CSharp) Method

ToManagedImageTest() private method

private ToManagedImageTest ( PixelFormat pixelFormat, int x, int y, byte red, byte green, byte blue ) : void
pixelFormat PixelFormat
x int
y int
red byte
green byte
blue byte
return void
        public void ToManagedImageTest(PixelFormat pixelFormat, int x, int y, byte red, byte green, byte blue)
        {
            UnmanagedImage image = UnmanagedImage.Create(320, 240, pixelFormat);

            image.SetPixel(new IntPoint(x, y), Color.FromArgb(255, red, green, blue));

            Bitmap bitmap = image.ToManagedImage();

            // check colors of pixels
            Assert.AreEqual(Color.FromArgb(255, red, green, blue), bitmap.GetPixel(x, y));

            // make sure there are only 1 pixel
            UnmanagedImage temp = UnmanagedImage.FromManagedImage(bitmap);

            List<IntPoint> pixels = temp.CollectActivePixels();
            Assert.AreEqual(1, pixels.Count);

            image.Dispose();
            bitmap.Dispose();
            temp.Dispose();
        }
    }