This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dotnet/load-a-file/imaging/from-byte-array-dicom.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Load a DICOM image from byte array in C# .NET | Nutrient .NET SDK
DICOM

To load a DICOM image from a byte array, use the CreateGdPictureImageFromByteArray method of the GdPictureImaging class.

This method returns a non-zero GdPicture image identifier (imageID) on success. If it fails, it returns 0 — use GetStat() to view the failure reason.

Overloads:

  • CreateGdPictureImageFromByteArray(byte[] Data)
  • CreateGdPictureImageFromByteArray(byte[] Data, DocumentFormat ImageFormat)

For DICOM byte content, the default overload is typically used so the toolkit auto-detects the format.

If the loaded DICOM has multiple pages/frames, you can use:

When you no longer need the image resource, release it with the ReleaseGdPictureImage method.

To load a DICOM image from a byte array, use the following code:

using GdPicture14;
using System;
using System.IO;
using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Create a byte array from a DICOM file.
byte[] byteArray = File.ReadAllBytes(@"C:\temp\source.dcm");
// Create a GdPicture image from the byte array.
int imageID = gdpictureImaging.CreateGdPictureImageFromByteArray(byteArray);
if (imageID == 0)
{
Console.WriteLine($"CreateGdPictureImageFromByteArray failed: {gdpictureImaging.GetStat()}");
return;
}
int pageCount = gdpictureImaging.DicomGetPageCount(imageID);
if (pageCount > 1)
{
GdPictureStatus selectStatus = gdpictureImaging.DicomSelectPage(imageID, 1);
if (selectStatus != GdPictureStatus.OK)
{
Console.WriteLine($"DicomSelectPage failed: {selectStatus}");
gdpictureImaging.ReleaseGdPictureImage(imageID);
return;
}
}
GdPictureStatus saveStatus = gdpictureImaging.SaveAsPNG(imageID, @"C:\temp\output.png");
if (saveStatus != GdPictureStatus.OK)
{
Console.WriteLine($"SaveAsPNG failed: {saveStatus}");
}
gdpictureImaging.ReleaseGdPictureImage(imageID);