VintaSoft Imaging .NET SDK 14.0: Documentation for .NET developer
Vintasoft.Imaging.Codecs.ImageFiles.Dicom Namespace / DicomFrame Class / GetImage Methods / GetImage(DecodingSettings,Boolean,EventHandler<ProgressEventArgs>) Method
Syntax Exceptions Example Requirements SeeAlso
In This Topic
    GetImage(DecodingSettings,Boolean,EventHandler<ProgressEventArgs>) Method (DicomFrame)
    In This Topic
    Returns an image with overlay images of the DICOM frame.
    Syntax

    Parameters

    progressDelegate
    Progress delegate.
    overlayAll
    A value indicating whether page must return image with overlay images.
    decodingSettings
    The decoding settings that should be used for decoding of page image.

    Return Value

    The image associated with this DicomFrame object if image was loaded successfully; otherwise, null.
    Exceptions
    ExceptionDescription
    Thrown if error occurred while loading of image.
    Example

    This C#/VB.NET code shows how to get a DICOM image with overlays and save it as PNG file.

    
    ''' <summary>
    ''' Returns DICOM image with overlay objects and saves it to a PNG file.
    ''' </summary>
    ''' <param name="filePath">Path to DICOM file.</param>
    ''' <param name="pageIndex">Index of DICOM page.</param>
    Public Sub GetAndSaveDicomImageWithOverlays(filePath As String, pageIndex As Integer)
        ' open DICOM file
        Using dicomFile As New Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFile(filePath)
            ' get DICOM page
            Dim frame As Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFrame = DirectCast(dicomFile.Pages(pageIndex), Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFrame)
            ' return DICOM image with overlay objects
            Using image As Vintasoft.Imaging.VintasoftImage = frame.GetImage(Nothing, True, Nothing)
                ' save image to a PNG file
                image.Save("E:\DicomImage.png")
            End Using
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Returns DICOM image with overlay objects and saves it to a PNG file.
    /// </summary>
    /// <param name="filePath">Path to DICOM file.</param>
    /// <param name="pageIndex">Index of DICOM page.</param>
    public void GetAndSaveDicomImageWithOverlays(string filePath, int pageIndex)
    {
        // open DICOM file
        using (Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFile dicomFile =
            new Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFile(filePath))
        {
            // get DICOM page
            Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFrame frame =
                (Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFrame)dicomFile.Pages[pageIndex];
            // return DICOM image with overlay objects
            using (Vintasoft.Imaging.VintasoftImage image = frame.GetImage(null, true, null))
            {
                // save image to a PNG file
                image.Save(@"E:\DicomImage.png");
            }
        }
    }
    
    

    Requirements

    Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also