←Select platform

SetBinaryValue(DicomElement,string) Method

Summary
Sets the binary value of an element.
Syntax
C#
C++/CLI
public bool SetBinaryValue( 
   DicomElement element, 
   string fileName 
) 
public: 
bool SetBinaryValue(  
   DicomElement^ element, 
   String^ fileName 
)  

Parameters

element
An item in the Data Set.

fileName
Path name of the file that contains the binary value to set.

Return Value

True if the binary value of the Data Element was set successfully. false, if it could not set the binary value of the Data Element.

Remarks

This method overwrites the value of the Data Element. The Value Length of the Data Element is then equal to the file length.

Example

This example will replace the video stored in an existing DICOM Dataset with another one. The replacement video should have the same format, frame rate and compression as the originally stored one.

Note: This example assumes the replacement video has all the correct characteristics of a Dicom video and assumes that the tags found in the original dataset matches the video specs as well, if you need higher level video processing you need to use the medical SDK, which is supported only via the LEADTOOLS Medical Module.

C#
using Leadtools; 
using Leadtools.Dicom; 
 
 
public void Test_DicomDataSet_ReplaceVideoExample() 
{ 
   string src = Path.Combine(LEAD_VARS.ImagesDir, "DICOM", @"DaDa_DVD_MPEG2.dcm"); 
   string videoFile = Path.Combine(LEAD_VARS.MediaDir, @"DaDa_DVD_MPEG2.mpg"); 
   string target = Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "target.dcm"); 
 
   DicomEngine.Startup(); 
   DicomDataSet ds = new DicomDataSet(); 
   ds.Load(src, DicomDataSetLoadFlags.None); 
 
   var pixelDataElement = ds.FindFirstElement(null, DicomTag.PixelData, true); 
   var itemElement = ds.GetChildElement(pixelDataElement, true); 
   itemElement = ds.GetNextElement(itemElement, true, true); 
 
   ds.SetBinaryValue(itemElement, videoFile); 
 
   ds.Save(target, 0); 
   DicomEngine.Shutdown(); 
   Console.WriteLine("Test_DicomDataSet_ReplaceVideoExample Finished"); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
   public const string MediaDir = @"C:\LEADTOOLS23\Media"; 
} 
Requirements

Target Platforms

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

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