Saturday, June 30, 2012

Convert DICOM to Bitmap in 3 lines of code

In an earlier post I covered how to convert JPEG to DICOM and also PDF and Bitmap to DICOM. In this very short post I'm going to show the opposite direction, which is much simpler,  converting DICOM to Bitmap.
With MODALIZER-SDK this is very simple. Here's the C# code:


            DCXIMG img = new DCXIMG();
            img.LoadFile(dcmfile.Text);
            img.SaveBitmap(0, bmpFile.Text);


dcmfile and bmpFile in this example are text boxes.
SaveBitmap first parameter is the frame number (0 based index) as a DICOM file may have many frames in it.
The DCXIMG class takes care of all conversions and decoding of the image if the pixel data in the DICOM file is compressed.
That's it on this subject. Comments and questions are most welcome.

3 comments:

  1. Any way to do the DICOM to .BMP conversion using a compiler like Lazarus? Similar to Delphi, but not quite as complex as my old Borland product that I got tired of paying way too much to upgrade every several months for.

    If not, do you have a simple .EXE that is compatible with Win7 that can convert the files available in regard to a dislocated R toe on a pt. on?

    ReplyDelete
  2. When I create an object of DCXIMG, dll gives me error that class not registered, I have already run the regserv32.exe command but its not working for me

    ReplyDelete