public void ShouldThrowExceptionWhenByteArrayIsSpecifiedAndGeometryIsNull() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.Throws <ArgumentNullException>("geometry", () => { pixels.SetArea(null, new byte[] { 0 }); }); } } }
public void ShouldChangePixelsWhenGeometryAndByteArrayAreSpecified() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { 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 ShouldThrowExceptionWhenByteArrayHasInvalidSize() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.Throws <ArgumentException>("values", () => { pixels.SetArea(10, 10, 1000, 1000, new byte[] { 0, 0, 0, 0 }); }); } } }
public void ShouldChangePixelsWhenByteArrayHasMaxNumberOfValues() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { var values = new byte[113 * 108 * image.ChannelCount]; pixels.SetArea(10, 10, 113, 108, values); ColorAssert.AreEqual(MagickColors.Black, image, image.Width - 1, image.Height - 1); } } }
public void ShouldThrowExceptionWhenByteArrayIsNull() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.Throws <ArgumentNullException>("values", () => { pixels.SetArea(10, 10, 1000, 1000, (byte[])null); }); } } }
public void SetAreaWithArray_MaxNumberOfValues_ChangesPixels() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { 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 SetAreaWithArray_InvalidSize_ThrowsException() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.ThrowsArgumentException("values", () => { pixels.SetArea(10, 10, 1000, 1000, new QuantumType[] { 0, 0, 0, 0 }); }); } } }
static void SetLinearPixel(IPixelCollection p, float[] pixel, long offset, int width) { int y = (int)(offset / width); int x = (int)(offset % width); p.SetArea(x, y, 1, 1, pixel); //Debug.WriteLine("set "+offset+"\t["+x+","+y+"]" // +"\t"+BitConverter.ToString(BitConverter.GetBytes(pixel[0]),0) // +"\t"+BitConverter.ToString(BitConverter.GetBytes(pixel[1]),0) // +"\t"+BitConverter.ToString(BitConverter.GetBytes(pixel[2]),0) // +"\t"+BitConverter.ToString(BitConverter.GetBytes(pixel[3]),0) //); }
public void ShouldThrowExceptionWhenByteArrayHasTooManyValues() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.ThrowsArgumentException("values", () => { var values = new byte[(113 * 108 * image.ChannelCount) + image.ChannelCount]; pixels.SetArea(10, 10, 113, 108, values); }); } } }
public void SetAreaWithArray_TooManyValues_ThrowsException() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.ThrowsArgumentException("values", () => { var values = new QuantumType[(113 * 108 * image.ChannelCount) + image.ChannelCount]; pixels.SetArea(10, 10, 113, 108, values); }); } } }