←Select platform

BulkData Property

Summary

Gets or sets a byte array representing the Bulkdata resource value (DICOM PS3.18) of the element.

Syntax

C#
C++/CLI
public byte[] BulkData { get; set; } 
public:  
   property array<Byte>^ BulkData 
   { 
      array<Byte>^ get() 
      void set(array<Byte>^ value) 
   } 

Property Value

A byte array representing the Bulkdata resource value (DICOM PS3.18) of the element.

Remarks

Modifying ElementValue changes the value that will be written for the DicomElement.

There are four ways to modify BulkData:

  1. Setting the BulkData property

  2. Calling [SetBulkData(byte[])] with a byte array.

  3. Calling SetBulkData(RasterImage,int) with a RasterImage and a quality factor.

  4. Calling SetBulkData(Stream) with Stream.

Example

C#
using Leadtools.Dicom; 
using Leadtools.Dicom.Common; 
using Leadtools.Dicom.Common.Extensions; 
using Leadtools; 
using Leadtools.Dicom.Common.Linq.BasicDirectory; 
using Leadtools.Dicom.Common.DataTypes; 
 
using Leadtools.Codecs; 
 
public static class SetBulkDataExample 
{ 
   public static bool MyLoadJsonBeforeElementCallback(LoadJsonBeforeElementData elementData) 
   { 
      // You can change the TransferSyntax here to any valid TransferSyntax 
      // Setting the TransferSyntax ElementValue to empty defaults the transfer syntax to Explicit VR Little Endian 
      //if (elementData.Tag == DicomTag.TransferSyntaxUID) 
      //{ 
      //   elementData.ElementValue = string.Empty; 
      //} 
 
      if (elementData.Encoding == ElementDataType.BulkData) 
      { 
         // If elementData.Encoding is ElementDataType.BulkData, then the BulkDataUri is returned in elementData.ElementValue 
         Console.WriteLine($"BulkDataUri: {elementData.ElementValue}"); 
 
         // Set the bulk data: four ways to do it 
         // 
 
         string rawImagePath = Path.Combine(LEAD_VARS.ImagesDir, "image2.jpg"); 
         string pngImagePath = Path.Combine(LEAD_VARS.ImagesDir, "PngImage.png"); 
 
         // Method 1: Setting the [BulkData] property 
         using (FileStream fs = new FileStream(rawImagePath, FileMode.Open)) 
         { 
            using (MemoryStream ms = new MemoryStream()) 
            { 
               fs.CopyTo(ms); 
               elementData.BulkData = ms.ToArray(); 
            } 
         } 
 
         // Method 2: Calling SetBulkData() with a byte array 
         using (FileStream fs = new FileStream(rawImagePath, FileMode.Open)) 
         { 
            using (MemoryStream ms = new MemoryStream()) 
            { 
               fs.CopyTo(ms); 
               elementData.SetBulkData(ms.ToArray()); 
            } 
         } 
 
         // Method 3 
         // Set the bulk data using a RasterImage 
         using (RasterCodecs codecs = new RasterCodecs()) 
         { 
            using (Leadtools.RasterImage image = codecs.Load(pngImagePath)) 
            { 
               // The second argument is optional and specifies the QFactor 
               elementData.SetBulkData(image, 2); 
            } 
         } 
 
         // Method 4 
         // In this example(image2.dcm) it is raw jpeg data 
         // For uncompressed DICOM data, pass the raw uncompressedData 
         using (FileStream fs = new FileStream(rawImagePath, FileMode.Open)) 
         { 
            elementData.SetBulkData(fs); 
         } 
      } 
      return true; 
   } 
 
   public static void MyLoadJson() 
   { 
      string dicomPath = Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "image2.dcm"); 
      string jsonPath = Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "image2.json"); 
 
      using (DicomDataSet dsJson = new DicomDataSet()) 
      { 
         dsJson.Load(dicomPath, DicomDataSetLoadFlags.None); 
         dsJson.SaveJson(jsonPath, DicomDataSetSaveJsonFlags.IgnoreBinaryData); 
      } 
 
      using (DicomDataSet ds = new DicomDataSet()) 
      { 
         ds.LoadJson(jsonPath, DicomDataSetLoadJsonFlags.None, MyLoadJsonBeforeElementCallback, null); 
      } 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 

Requirements

Target Platforms

See Also

LoadBeforeElementData Class

LoadBeforeElementData Members

Leadtools.Dicom.Common.Extensions Namespace

[SetBulkData(byte[])]:../dco/Extensions-LoadBeforeElementData-SetBulkData(byte[]).md

Help Version 22.0.2023.1.30
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Dicom.Common Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.