/// <summary> /// Writes the images to the specified buffer writter. If the output image's file format does not /// allow multi-image files multiple files will be written. /// </summary> /// <param name="bufferWriter">The buffer writer to write the images to.</param> /// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception> public void Write(IBufferWriter <byte> bufferWriter) { Throw.IfNull(nameof(bufferWriter), bufferWriter); if (_images.Count == 0) { return; } var settings = GetSettings().Clone(); settings.FileName = null; try { AttachImages(); var wrapper = new BufferWriterWrapper(bufferWriter); var writer = new ReadWriteStreamDelegate(wrapper.Write); _nativeInstance.WriteStream(_images[0], settings, writer, null, null, null); } finally { DetachImages(); } }
/// <summary> /// Writes the image to the specified file. /// </summary> /// <param name="bufferWriter">The buffer writer to write the image to.</param> /// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception> public void Write(IBufferWriter <byte> bufferWriter) { Throw.IfNull(nameof(bufferWriter), bufferWriter); _settings.FileName = null; var wrapper = new BufferWriterWrapper(bufferWriter); var writer = new ReadWriteStreamDelegate(wrapper.Write); _nativeInstance.WriteStream(_settings, writer, null, null, null); }