///<summary>
/// Writes the imagse to the specified stream. If the output image's file format does not
/// allow multi-image files multiple files will be written.
///</summary>
///<param name="stream">The stream to write the images to.</param>
///<exception cref="MagickException"/>
public void Write(Stream stream)
{
Throw.IfNull("stream", stream);
if (_Images.Count == 0)
{
return;
}
MagickSettings settings = _Images[0].Settings;
settings.FileName = null;
try
{
AttachImages();
UIntPtr length;
IntPtr data = _NativeInstance.WriteBlob(_Images[0], settings, out length);
MagickMemory.WriteBytes(data, length, stream);
}
finally
{
DetachImages();
}
}