public void ShouldThrowExceptionWhenByteArrayIsEmptyAndPixelStorageSettingsIsSpecified() { ExceptionAssert.ThrowsArgumentException("data", () => { var pixelStorageSettings = new PixelStorageSettings(); new MagickImage(new byte[] { }, pixelStorageSettings); }); }
public void ShouldThrowExceptionWhenFileInfoIsNullAndPixelStorageSettingsIsSpecified() { ExceptionAssert.ThrowsArgumentNullException("file", () => { var pixelStorageSettings = new PixelStorageSettings(); new MagickImage((FileInfo)null, pixelStorageSettings); }); }
public void ShouldThrowExceptionWhenMappingIsEmpty() { ExceptionAssert.ThrowsArgumentException("pixelStorageSettings", () => { var settings = new PixelStorageSettings(1, 1, StorageType.Char, string.Empty); new MagickImage(Files.CirclePNG, settings); }, "mapping"); }
public void ShouldThrowExceptionWhenStreamIsEmptyAndPixelStorageSettingsIsSpecified() { ExceptionAssert.ThrowsArgumentException("stream", () => { var pixelStorageSettings = new PixelStorageSettings(); new MagickImage(new MemoryStream(), pixelStorageSettings); }); }
public void ShouldThrowExceptionWhenStreamIsNullAndPixelStorageSettingsIsSpecified() { ExceptionAssert.ThrowsArgumentNullException("stream", () => { var pixelStorageSettings = new PixelStorageSettings(); new MagickImage((Stream)null, pixelStorageSettings); }); }
public void ShouldThrowExceptionWhenFileNameIsNullAndPixelStorageSettingsIsSpecified() { ExceptionAssert.ThrowsArgumentNullException("fileName", () => { var pixelStorageSettings = new PixelStorageSettings(); MagickFactory factory = new MagickFactory(); factory.CreateImage((string)null, pixelStorageSettings); }); }
public void ShouldThrowExceptionWhenMappingIsNull() { ExceptionAssert.ThrowsArgumentException("pixelStorageSettings", () => { var settings = new PixelStorageSettings(1, 1, StorageType.Char, null); MagickFactory factory = new MagickFactory(); factory.CreateImage(Files.CirclePNG, settings); }, "mapping"); }
public void ShouldThrowExceptionWhenByteArrayIsNullAndPixelStorageSettingsIsSpecified() { ExceptionAssert.ThrowsArgumentNullException("data", () => { var pixelStorageSettings = new PixelStorageSettings(); MagickFactory factory = new MagickFactory(); factory.CreateImage((byte[])null, pixelStorageSettings); }); }
public void ShouldThrowExceptionWhenHeightIsNull() { ExceptionAssert.ThrowsArgumentException("pixelStorageSettings", () => { var settings = new PixelStorageSettings(1, 1, StorageType.Char, "RGBA"); settings.ReadSettings.Height = null; new MagickImage(Files.CirclePNG, settings); }, "Height"); }
public void ShouldSetTheMappingCorrectly() { var settings = new PixelStorageSettings(1, 2, StorageType.Int64, PixelMapping.CMYK); Assert.IsNotNull(settings.ReadSettings); Assert.AreEqual(1, settings.ReadSettings.Width); Assert.AreEqual(2, settings.ReadSettings.Height); Assert.AreEqual(StorageType.Int64, settings.StorageType); Assert.AreEqual("CMYK", settings.Mapping); }
public void ShouldSetTheProperties() { var settings = new PixelStorageSettings(3, 4, StorageType.Quantum, "CMY"); Assert.IsNotNull(settings.ReadSettings); Assert.AreEqual(3, settings.ReadSettings.Width); Assert.AreEqual(4, settings.ReadSettings.Height); Assert.AreEqual(StorageType.Quantum, settings.StorageType); Assert.AreEqual("CMY", settings.Mapping); }
public void ShouldSetTheProperties() { var readSettings = new MagickReadSettings(); var pixelStorageSettings = new PixelStorageSettings(); var eventArgs = new ScriptReadEventArgs("test", readSettings, pixelStorageSettings); Assert.AreEqual("test", eventArgs.Id); Assert.AreEqual(readSettings, eventArgs.ReadSettings); Assert.AreEqual(pixelStorageSettings, eventArgs.PixelStorageSettings); }
public void ShouldThrowExceptionWhenWidthIsNull() { ExceptionAssert.ThrowsArgumentException("pixelStorageSettings", () => { var settings = new PixelStorageSettings(1, 1, StorageType.Char, "RGBA"); settings.ReadSettings.Width = null; MagickFactory factory = new MagickFactory(); factory.CreateImage(Files.CirclePNG, settings); }, "Width"); }
public void ShouldThrowExceptionWhenFileNameIsNullAndPixelStorageSettingsIsSpecified() { ExceptionAssert.ThrowsArgumentNullException("fileName", () => { var pixelStorageSettings = new PixelStorageSettings(); using (IMagickImage image = new MagickImage()) { image.ReadPixels((string)null, pixelStorageSettings); } }); }
public void ShouldThrowExceptionWhenByteArrayIsNullAndPixelStorageSettingsIsSpecified() { ExceptionAssert.ThrowsArgumentNullException("data", () => { var pixelStorageSettings = new PixelStorageSettings(); using (IMagickImage image = new MagickImage()) { image.ReadPixels((byte[])null, pixelStorageSettings); } }); }
public void ShouldThrowExceptionWhenMappingIsNull() { ExceptionAssert.ThrowsArgumentException("pixelStorageSettings", () => { var settings = new PixelStorageSettings(1, 1, StorageType.Char, null); using (IMagickImage image = new MagickImage()) { image.ReadPixels(Files.CirclePNG, settings); } }, "mapping"); }
public void ShouldThrowExceptionWhenWidthIsNull() { ExceptionAssert.ThrowsArgumentException("pixelStorageSettings", () => { var settings = new PixelStorageSettings(1, 1, StorageType.Char, "RGBA"); settings.ReadSettings.Width = null; using (IMagickImage image = new MagickImage()) { image.ReadPixels(Files.CirclePNG, settings); } }, "Width"); }
public void ShouldReadStreamWithPixelStorageSettings() { var pixelStorageSettings = new PixelStorageSettings(1, 1, StorageType.Double, "R"); var bytes = BitConverter.GetBytes(1.0); using (var memoryStream = new MemoryStream(bytes)) { using (IMagickImage image = new MagickImage(memoryStream, pixelStorageSettings)) { Assert.AreEqual(1, image.Width); Assert.AreEqual(1, image.Height); ColorAssert.AreEqual(MagickColors.White, image, 0, 0); } } }
public void ShouldReadFileInfoWithPixelStorageSettings() { var pixelStorageSettings = new PixelStorageSettings(1, 1, StorageType.Quantum, "R"); var bytes = BitConverter.GetBytes(Quantum.Max); using (var temporyFile = new TemporaryFile(bytes)) { FileInfo file = temporyFile; using (IMagickImage image = new MagickImage(file, pixelStorageSettings)) { Assert.AreEqual(1, image.Width); Assert.AreEqual(1, image.Height); ColorAssert.AreEqual(MagickColors.White, image, 0, 0); } } }
public void ShouldReadFileNameWithPixelStorageSettings() { var pixelStorageSettings = new PixelStorageSettings(1, 1, StorageType.Int32, "R"); var bytes = BitConverter.GetBytes(4294967295U); using (var temporyFile = new TemporaryFile(bytes)) { var fileName = temporyFile.FullName; using (IMagickImage image = new MagickImage(fileName, pixelStorageSettings)) { Assert.AreEqual(1, image.Width); Assert.AreEqual(1, image.Height); ColorAssert.AreEqual(MagickColors.White, image, 0, 0); } } }
public void ShouldReadByteArrayWithPixelStorageSettings() { byte[] data = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xf0, 0x3f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xf0, 0x3f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; var pixelStorageSettings = new PixelStorageSettings(2, 1, StorageType.Double, PixelMapping.RGBA); MagickFactory factory = new MagickFactory(); using (IMagickImage image = factory.CreateImage(data, pixelStorageSettings)) { Assert.AreEqual(2, image.Width); Assert.AreEqual(1, image.Height); using (IPixelCollection pixels = image.GetPixels()) { Pixel pixel = pixels.GetPixel(0, 0); Assert.AreEqual(4, pixel.Channels); Assert.AreEqual(0, pixel.GetChannel(0)); Assert.AreEqual(0, pixel.GetChannel(1)); Assert.AreEqual(0, pixel.GetChannel(2)); Assert.AreEqual(Quantum.Max, pixel.GetChannel(3)); pixel = pixels.GetPixel(1, 0); Assert.AreEqual(4, pixel.Channels); Assert.AreEqual(0, pixel.GetChannel(0)); Assert.AreEqual(Quantum.Max, pixel.GetChannel(1)); Assert.AreEqual(0, pixel.GetChannel(2)); Assert.AreEqual(0, pixel.GetChannel(3)); } } }
public void ShouldSetTheReadSettings() { var settings = new PixelStorageSettings(); Assert.IsNotNull(settings.ReadSettings); }