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();
}
}