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:
c# asp.net word document viewer: ASP.NET Office Word Document Viewer: view Word doc files online using C# in ASP.NET MVC web applications
asp.net edit pdf image using c#: ASP.NET PDF Image Edit Control: online insert, edit PDF images in C#
c# asp.net dicom viewer: ASP.NET Dicom Document Viewer Control: view, annotate dicom imaging files online in ASP.NET
asp.net document viewer open source: EdgeDoc:ASP.NET Document Viewer C# Control: Open, view, annotate, redact, convert documents online in C#, VB.NET, AS...
asp.net edit pdf page using c#: ASP.NET PDF Pages Edit Control: add, remove, sort, replace PDF pages online using C#
asp.net pdf viewer using c#: ASP.NET PDF Viewer Control: view, navigate, zoom Adobe PDF document in C# ASP.NET
c# asp.net mvc document viewer: ASP.NET Document Viewer using C#: Open, View, Annotate, Redact, Convert document files in ASP.NET using C#, HTML5, JQuer...


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.