Convert DICOM to PNG using C#

This article guides on how to convert DICOM to PNG using C#. All the details related to the environment settings, the programming steps, and sample code for converting DCM to PNG using C#. You will learn to transform all or some selected scenes from the DICOM medical images to PNG format for distribution.

Steps to Convert DCM to PNG using C#

  1. Install and add a reference to the Aspose.Imaging library into your application
  2. Load Aspose.Imaging license using SetLicense to enable full library features
  3. Load the DICOM file using Image.Load and cast it to DicomImage
  4. Display the total number of pages in the DICOM file using the image.PageCount property
  5. Create an empty PngOptions object to define the image export settings
  6. Iterate through all pages in the DICOM image using a for loop
  7. Save each page as a separate PNG file with a unique filename like Page-0.png, Page-1.png, etc.

These steps assist in developing a DICOM to PNG converter using C#. First, load the Aspose.Imaging license and open the DICOM file as a DicomImage, then check the total number of pages and prepare PNG export settings. Loop through each page, save it as a separate PNG file, and display a success message upon completion.

Code to Change DICOM to PNG using C#

This code demonstrates the conversion of the file format from DCM to PNG. You may load images from a stream with LoadOptions to control buffer size, for example, to limit memory usage. Multiple options are available to customize the output PNG, such as specifying the color, compression, and DPI settings.

This article has taught us the process to transform DICOM file to PNG. To convert CDR to JPG, refer to the article on Convert CDR to JPG using C#.

 English