Save

DicomImage.Save method

Easily save your image data to a specified stream in the desired file format using this convenient method. Whether you’re working with JPEG, PNG, or another format, this function ensures that your image data is saved efficiently and accurately, making it ideal for developers looking to streamline their file-saving processes.

public override void Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
ParameterTypeDescription
streamStreamThe stream to save the image’s data to.
optionsBaseImageOptionsBaseThe save options.
boundsRectangleRectangleThe destination image bounds rectangle. Set the empty rectangle for use sourse bounds.

Examples

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

[C#]

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