//=========================================================================================== private static void Test_Set(WritablePixelCollection pixels, QuantumType[] value) { ExceptionAssert.Throws <ArgumentException>(delegate() { pixels.Set(value); }); }
public void Test_Write() { using (MagickImage image = new MagickImage(Color.Red, 10, 1)) { using (WritablePixelCollection pixels = image.GetWritablePixels()) { byte[] bytes = new byte[10 * pixels.Channels]; for (int i = 0; i < bytes.Length; i++) { bytes[i] = 0; } pixels.Set(bytes); pixels.Write(); } TestPixels(image, new MagickColor(0, 0, 0)); using (WritablePixelCollection pixels = image.GetWritablePixels()) { foreach (Pixel pixel in pixels) { pixel.SetChannel(2, Quantum.Max); } pixels.Write(); } TestPixels(image, Color.Blue); } }
private static void Test_Set(WritablePixelCollection pixels, QuantumType[] value) { ExceptionAssert.Throws<ArgumentException>(delegate () { pixels.Set(value); }); }
private static void Test_PixelColor(WritablePixelCollection pixels, Color color) { var values = pixels.GetValue(0, 0); Assert.AreEqual(3, values.Length); MagickColor magickColor = new MagickColor(values[0], values[1], values[2]); ColorAssert.AreEqual(color, magickColor); }
public void Test_Set() { using (MagickImage image = new MagickImage(Color.Red, 5, 10)) { using (WritablePixelCollection pixels = image.GetWritablePixels()) { ExceptionAssert.Throws <ArgumentNullException>(delegate() { pixels.Set((QuantumType[])null); }); ExceptionAssert.Throws <ArgumentNullException>(delegate() { pixels.Set((Pixel)null); }); ExceptionAssert.Throws <ArgumentNullException>(delegate() { pixels.Set((Pixel[])null); }); Test_Set(pixels, new QuantumType[] { }); Test_Set(pixels, new QuantumType[] { 0 }); Test_Set(pixels, new QuantumType[] { 0, 0 }); Test_Set(pixels, new QuantumType[] { 0, 0, 0 }); pixels.Set(new QuantumType[] { 0, 0, 0, 0, 0 }); Test_PixelColor(pixels, Color.Black); pixels.Write(); } using (PixelCollection pixels = image.GetReadOnlyPixels()) { Test_PixelColor(pixels, Color.Black); } using (WritablePixelCollection pixels = image.GetWritablePixels()) { pixels.Set(new uint[] { 4294967295, 0, 0, 0, 0 }); Test_PixelColor(pixels, Color.Red); pixels.Set(new ushort[] { 0, 0, 65535, 0, 0 }); Test_PixelColor(pixels, Color.Blue); pixels.Set(new byte[] { 0, 255, 0, 0, 0 }); Test_PixelColor(pixels, Color.Lime); } using (WritablePixelCollection pixels = image.GetWritablePixels()) { for (int x = 0; x < pixels.Width; x++) { for (int y = 0; y < pixels.Height; y++) { pixels.Set(x, y, new QuantumType[] { 0, 0, 0, 0, 0 }); } } } } }
public void Test_GetValue() { using (MagickImage image = new MagickImage(Color.Red, 5, 10)) { using (WritablePixelCollection pixels = image.GetWritablePixels()) { Test_PixelColor(pixels, Color.Red); } } }
public void Test_Dimensions() { using (MagickImage image = new MagickImage(Color.Red, 5, 10)) { using (WritablePixelCollection pixels = image.GetWritablePixels()) { Assert.AreEqual(5, pixels.Width); Assert.AreEqual(10, pixels.Height); Assert.AreEqual(5 * 10 * 5, pixels.GetValues().Length); } } }