public void ShouldChangePixelsWhenArrayHasMaxNumberOfValues() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixelsUnsafe()) { var values = new QuantumType[113 * 108 * image.ChannelCount]; pixels.SetArea(10, 10, 113, 108, values); ColorAssert.AreEqual(MagickColors.Black, image, image.Width - 1, image.Height - 1); } } }
public void ShouldChangePixelWhenTooManyChannelsAreSupplied() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixelsUnsafe()) { Pixel pixel = new Pixel(0, 0, new QuantumType[] { 0, 0, 0, 0 }); pixels.SetPixel(pixel); ColorAssert.AreEqual(MagickColors.Black, image, 0, 0); } } }
public void ShouldReturnAllPixels() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { var values = pixels.ToArray(); int length = image.Width * image.Height * image.ChannelCount; Assert.AreEqual(length, values.Length); } } }
public void ShouldThrowExceptionWhenGeometryIsSpecifiedAndMappingIsEmpty() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixelsUnsafe()) { ExceptionAssert.Throws <MagickResourceLimitErrorException>(() => { var values = pixels.ToByteArray(new MagickGeometry(1, 2, 3, 4), string.Empty); }); } } }
public void ShouldThrowExceptionWhenOffsetWidthIsOutsideImage() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixelsUnsafe()) { ExceptionAssert.Throws <MagickCacheErrorException>(() => { pixels.SetPixel(image.Width + 1, 0, new QuantumType[] { 0 }); }); } } }
public void ShouldThrowExceptionWhenMappingIsEmpty() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixelsUnsafe()) { ExceptionAssert.Throws <MagickResourceLimitErrorException>(() => { pixels.ToByteArray(string.Empty); }); } } }
public void ShouldReturnArrayWhenTwoChannelsAreSupplied() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixelsUnsafe()) { var values = pixels.ToByteArray("RG"); int length = image.Width * image.Height * 2; Assert.AreEqual(length, values.Length); } } }
public void ShouldThrowExceptionWhenWidthZero() { using (IMagickImage image = new MagickImage(MagickColors.Red, 5, 10)) { using (IPixelCollection pixels = image.GetPixelsUnsafe()) { ExceptionAssert.Throws <InvalidOperationException>(() => { pixels.GetArea(0, 0, 0, 1); }); } } }
public void ShouldThrowExceptionWhenMappingIsEmpty() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.ThrowsArgumentException("mapping", () => { pixels.ToByteArray(string.Empty); }); } } }
public void ShouldThrowExceptionWhenPixelWidthIsOutsideImage() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.ThrowsArgumentOutOfRangeException("x", () => { pixels.SetPixel(new Pixel(image.Width + 1, 0, 3)); }); } } }
public void ShouldThrowExceptionWhenWidthTooLow() { using (IMagickImage image = new MagickImage(MagickColors.Red, 5, 10)) { using (IPixelCollection pixels = image.GetPixelsUnsafe()) { ExceptionAssert.Throws <OverflowException>(() => { pixels.GetArea(0, 0, -1, 1); }); } } }
public void ShouldThrowExceptionWhenPixelIsNull() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.ThrowsArgumentNullException("pixel", () => { pixels.SetPixel((Pixel)null); }); } } }
public void ShouldThrowExceptionWhenArrayIsEmpty() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.ThrowsArgumentException("value", () => { pixels.SetPixel(0, 0, new QuantumType[] { }); }); } } }
public void ShouldChangePixelsWhenGeometryAndByteArrayAreSpecified() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixelsUnsafe()) { var values = new byte[113 * 108 * image.ChannelCount]; pixels.SetArea(new MagickGeometry(10, 10, 113, 108), values); ColorAssert.AreEqual(MagickColors.Black, image, image.Width - 1, image.Height - 1); } } }
public void ShouldThrowExceptionWhenDoubleArrayIsNull() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.ThrowsArgumentNullException("values", () => { pixels.SetPixels((double[])null); }); } } }
public void ShouldReturnArrayWhenTwoChannelsAreSuppliedAndMappingIsEnum() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { var values = pixels.ToByteArray(PixelMapping.RGB); int length = image.Width * image.Height * 3; Assert.AreEqual(length, values.Length); } } }
public void ShouldReturnArrayWhenGeometryIsCorrect() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixelsUnsafe()) { var values = pixels.ToByteArray(new MagickGeometry(10, 10, 113, 108), "RG"); int length = 113 * 108 * 2; Assert.AreEqual(length, values.Length); } } }
public void ShouldThrowExceptionWhenXTooLow() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.ThrowsArgumentOutOfRangeException("x", () => { pixels.ToByteArray(-1, 0, 1, 1, "RGB"); }); } } }
public void ShouldThrowExceptionWhenMappingIsInvalid() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixelsUnsafe()) { ExceptionAssert.Throws <MagickOptionErrorException>(() => { pixels.ToByteArray("FOO"); }); } } }
public void ShouldThrowExceptionWhenGeometryIsNullAndMappingIsEnum() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.ThrowsArgumentNullException("geometry", () => { pixels.ToByteArray(null, PixelMapping.RGB); }); } } }
public void ShouldReturnPixelsWhenAreaIsCorrecy() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixelsUnsafe()) { var values = pixels.ToByteArray(60, 60, 63, 58, "RGBA"); int length = 63 * 58 * 4; Assert.AreEqual(length, values.Length); } } }
public void ShouldThrowExceptionWhenGeometryIsSpecifiedAndMappingIsNull() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.ThrowsArgumentNullException("mapping", () => { pixels.ToByteArray(new MagickGeometry(1, 2, 3, 4), null); }); } } }
public void ShouldChangePixelWhenCompletePixelIsSupplied() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixelsUnsafe()) { Pixel pixel = new Pixel(0, 0, new QuantumType[] { 0, Quantum.Max, 0 }); pixels.SetPixel(pixel); ColorAssert.AreEqual(MagickColors.Lime, image, 0, 0); } } }
public void ShouldReturnArrayWhenGeometryIsCorrectAndMappingIsEnum() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixelsUnsafe()) { var values = pixels.ToShortArray(new MagickGeometry(10, 10, 113, 108), PixelMapping.RGB); var length = 113 * 108 * 3; Assert.AreEqual(length, values.Length); } } }
public void ShouldThrowExceptionWhenPixelHeightIsOutsideImage() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixelsUnsafe()) { ExceptionAssert.Throws <MagickCacheErrorException>(() => { pixels.SetPixel(new Pixel(0, image.Height + 1, 3)); }); } } }
public void ShouldThrowExceptionWhenByteArrayHasInvalidSize() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.ThrowsArgumentException("values", () => { pixels.SetPixels(new byte[] { 0, 0, 0, 0 }); }); } } }
public void ShouldThrowExceptionWhenHeightOutsideImage() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.ThrowsArgumentOutOfRangeException("y", () => { pixels.GetPixel(0, image.Height + 1); }); } } }
public void ShouldChangePixelsWhenByteArrayHasMaxNumberOfValues() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { var values = new byte[image.Width * image.Height * image.ChannelCount]; pixels.SetPixels(values); ColorAssert.AreEqual(MagickColors.Black, image, image.Width - 1, image.Height - 1); } } }
public void ShouldReturnAllPixels() { using (IMagickImage image = new MagickImage(MagickColors.Purple, 4, 2)) { using (IPixelCollection pixels = image.GetPixels()) { var values = pixels.GetValues(); int length = 4 * 2 * 3; Assert.AreEqual(length, values.Length); } } }
private static void ThrowsArgumentException(string paramName, int x, int y, int width, int height) { using (IMagickImage image = new MagickImage(MagickColors.Red, 5, 10)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.Throws <ArgumentOutOfRangeException>(paramName, () => { pixels.GetArea(x, y, width, height); }); } } }