How to Load a DICOM File From a Byte Array

Posted on 2016-10-07 10:48:09 by Greg

More often than not, DICOM files are loaded from a location on disk due to the size and complexity of the files. However, no environment and scenario is the same and we periodically get requests regarding how to load DICOM files from memory, more specifically a byte[] rather than a Stream. Due to the way that .NET garbage collection works we must use a .NET GCHandle object when passing an IntPtr to the overloaded DicomDataSet.Load function.


private byte[] loadedFile; // byte array for DICOM file from database, server, etc.
private DicomDataSet dicomDS;
private DicomElement element;

// Pin object so it is not garbage collected before work is done.
GCHandle gch = GCHandle.Alloc(loadedFile);

// Load DicomDS from byte[] using IntPtr of array.
dicomDS.Load(Marshal.UnsafeAddrOfPinnedArrayElement(loadedFile, 0),
   loadedFile.Length, DicomDataSetFlags.None);

// Unpin object.
gch.Free();

// Get image from DicomDS.
element = dicomDS.FindFirstElement(null, DicomTag.PixelData, true);
rasterImageViewer1.Image = dicomDS.GetImage(element, 0, 0,
   Leadtools.RasterByteOrder.Gray, DicomGetImageFlags.None);

To download the entire C# example project for versions 17.5 and 18, check out this forum post.

Continue Reading...

Major Update for LEADTOOLS 17.5 Released!

Posted on 2016-10-07 10:44:08 by Greg

Continue Reading...

HTML5 DICOM Cine

Posted on 2016-10-07 10:43:36 by Greg

Continue Reading...

Working HTML5 Group Annotations Programmatically - Plus a Sneak Peek at New Features

Posted on 2016-10-07 10:38:04 by Greg

This week I'd like to highlight another example project one of our support agents developed in response to a customer request. Group annotations are a necessary feature in any application utilizing annotations and markup. In fact, the LEADTOOLS HTML5 SDK includes support for group annotations out of the box by simply clicking and dragging with the select tool. However, this customer had a requirement to create and edit group annotations programmatically.

Here is how you create the annotations and then place them in groups. After that you can use the mouse to select, move and resize each group as if they were a single entity.

Continue Reading...

Using JSON in Android for DICOM Communication

Posted on 2016-10-07 10:01:20 by Greg

We have received several requests regarding PACS and DICOM Communication within our Android imaging SDK. One way of accomplishing this is by using JSON to communicate with the RESTful web services included with the HTML5 Zero Footprint DICOM Viewer.

The snippet below shows a portion of the asynchronous code that calls the RESTful Medical Viewer Service and then parses the JSON response to get the SOP Instance UID. After that, the SOP Instance UID is used to get the image data and put it into an InputStream.

Continue Reading...
LEADTOOLS Blog

LEADTOOLS Powered by Apryse,the Market Leading PDF SDK,All Rights Reserved