DicomImage.Save method

Saves the image’s data to the specified stream in the specified file format according to save options.

public override void Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
Parameter Type Description
stream Stream The stream to save the image’s data to.
optionsBase ImageOptionsBase The save options.
boundsRectangle Rectangle The destination image bounds rectangle. Set the empty rectangle for use sourse bounds.


The following example loads a DICOM image from a file, then saves the image to a PNG file stream.


string dir = "c:\\temp\\";

using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
    Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
    Aspose.Imaging.Rectangle bounds = new Aspose.Imaging.Rectangle(0, 0, image.Width / 2, image.Height / 2);
    using (System.IO.Stream outputStream = System.IO.File.Open(dir + "output.png", System.IO.FileMode.Create))
        // Save the upper-left quarter of the image to a file stream.
        image.Save(outputStream, saveOptions, bounds);

See Also