DicomObjects.NET.8.48 Documentation
DicomObjects Namespace / BitmapImage_Extensions Class / Save Method
BitmapImage to save
Stream that holds the output image
File format of the output image
Example

In This Topic
    Save Method
    In This Topic
    Save this BitmapImage to an output stream using the specified image format
    Syntax
    'Declaration
     
    
    <System.Runtime.CompilerServices.ExtensionAttribute()>
    Public Shared Sub Save( _
       ByVal BitmapImg As System.Windows.Media.Imaging.BitmapImage, _
       ByVal OutputStream As System.IO.Stream, _
       ByVal Format As System.String _
    ) 
    [System.Runtime.CompilerServices.Extension()]
    public static void Save( 
       System.Windows.Media.Imaging.BitmapImage BitmapImg,
       System.IO.Stream OutputStream,
       System.string Format
    )

    Parameters

    BitmapImg
    BitmapImage to save
    OutputStream
    Stream that holds the output image
    Format
    File format of the output image
    Example
    using System;
    using System.IO;
    using DicomObjects;
    using System.Windows.Media.Imaging;
                        
    // Require reference to PresentationCore.dll
    var bitmapImg = new BitmapImage(new Uri("path_to_your_image.jpg", UriKind.RelativeOrAbsolute));
                
    // Create a FileStream to save the image
    using (var outputStream = new FileStream("output_image.png", FileMode.Create))
    {
        // Specify the image format (e.g., "png", "jpeg")
        var format = "png";
                
        BitmapImage_Extensions.Save(bitmapImg, outputStream, format);
    }
    Requirements

    Target Platforms: .NET CLR 4.8 or higher

    See Also