C#: Online Guide
How To: Dicom SDK
Dicom to Bitmap
Dicom to Bitmap
  |  
Home ›› XDoc.Dicom ›› C# Dicom: Convert Dicom to Bitmap

C# DICOM - Convert DICOM to Bitmap Object


Render and Convert DICOM Image File to Bitmap Object(s) in C#.NET Program




C#.NET DICOM to Bitmap Conversion Overview



Considering that returning a Bitmap object are faster than returning a REImage (the core image class in RasterEdge DocImage SDK for .NET) object in some cases, for instance, no additional adjustments are needed for C#.NET DICOM conversion like setting window width and center, RasterEdge specially provides C# programmers with mature APIs to directly convert DICOM image file to Bitmap objects in C#.NET application, which can be then drew on graphics of controls, like WinForms control.


Related .net document control helps:
asp.net iis file viewer: C# HTML5 Viewer: Deployment on IIS
asp.net convert pdf control: ASP.NET Convert PDF Control: Convert, export PDF to Word, HTML, Tiff files in C# ASP.NET
asp.net dotnetnuke pdf editor control: ASP.NET DNN PDF Editor Control: view, edit PDF files in Dotnetnuke application
asp.net webforms pdf editor control: ASP.NET WebForms PDF Editor: create, view, edit, annotate, redact PDF file in ASP.NET WebForms application
asp.net pdf viewer control: ASP.NET PDF Viewer Control: view, navigate, zoom Adobe PDF document in C# ASP.NET
asp.net file viewer: EdgeDoc ASP.NET Document Viewer C# Control: Open, view, annotate, redact, convert documents online using ASP.NET Web Con...
asp.net sharepoint pdf editor control: ASP.NET SharePoint PDF Editor Control: view, edit, annotate, redact PDF document in SharePoint sites


In .NET Framework, Bitmap is a frequently used class in image processing. With the help of this C# guide, users can easily render and convert DICOM document (single page or multi-page) to Bitmap object(s) and then do advanced manipulations, like DICOM image file annotating.


Now, let's firstly have a look at the necessary .NET document imaging DLL assemblies that should be added to your Visual C#.NET project for conversion from DICOM image file to Bitmap object(s). In all, two DLLs should be used, including RasterEdge.Imaging.Basic.dll and RasterEdge.Imaging.DICOM.dll. By the way, before using RasterEdge DocImage SDK for .NET to perform C#.NET DICOM document conversion, please make sure you have installed these programs on your computer, including .NET Framework 2.0 or any later version and Visual Studio 2005 or any above version.




Demo Code for C#.NET DICOM to Bitmap Conversion



Add necessary references references;


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.Imaging.JPEG2000.dll


  RasterEdge.Imaging.DICOM.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.Imaging.DICOM;


In C#.NET DICOM document file conversion, if you don't need to adjust the rendering parameters like window width and center, the method GetBitmap(); is supposed to be used to return a better performance. And below is a snippet of C# demo code for DICOM to Bitmap rendering and converting.




DCMDocument dcm = new DCMDocument(@"C:\demo1.dcm");

//convert one page to png image
BasePage page = dcm.GetPage(0);
page.ConvertToImage(ImageType.BMP, @"C:\first.bmp");

//convert all pages to png images
dcm.ConvertToImages(ImageType.BMP, @"C:\", "test");



public override Bitmap ConvertToImage()

Return:
Null if failed.


public override Bitmap ConvertToImage(float zoomValue)
Parameters:

Return:
Null if failed.


public override Bitmap ConvertToImage(int targetResolution)
Parameters:

Return:
Null if failed


public override Bitmap ConvertToImage(Size targetSize)
Parameters:

Return:
Null if failed.


public override void ConvertToImage(ImageType targetType, string filePath)
Parameters:
public override void ConvertToImage(ImageType targetType, float zoomValue, string filePath)
Parameters:
public override void ConvertToImage(ImageType targetType, int resolution, string filePath)
Parameters:
public override byte[] ConvertToImageBytes(ImageType targetType)
Parameters:

Return:
Null if failed.


public override byte[] ConvertToImageBytes(ImageType targetType, float zoomValue)
Parameters:
public override byte[] ConvertToImageBytes(ImageType targetType, int targetResolution)
Parameters:
public override Bitmap ConvertToImageFitHeight(int height)
Parameters:

Return:
Null if failed.


public override Bitmap ConvertToImageFitWidth(int width)
Parameters:

Return:
Null if failed.


public override void ConvertToImageStream(ImageType targetType, Stream stream)
Parameters:
public override void ConvertToImageStream(ImageType targetType, float zoomValue, Stream stream)
Parameters:
public override void ConvertToImageStream(ImageType targetType, int resolution, Stream stream)
Parameters:
public override Bitmap CropImage(Rectangle sourceRegion, Size targetSize)
Parameters:

Return:
Null if failed.


public override Bitmap GetBitmap()

Return:
Null if failed.


public override Bitmap GetBitmap(float zoomValue)
Parameters:

Return:
Null if failed.


public override Bitmap GetBitmap(int resolution)
Parameters:

Return:
Null if failed.


public override Bitmap GetBitmap(Rectangle sourceRectangle, Size targetSize)
Parameters:

Return:
Null if failed.