public bool SetValue(
DicomElement element,
object value
)
public:
bool SetValue(
DicomElement^ element,
Object^ value
)
element
An item in the Data Set.
value
An Object that can be any supported type, or an array of any supported type.
true if the object value was set successfully. false if could not set the object value of the Data Element.
Note: The user is responsible to allocate the memory for value. This is very flexible function that can be used to set the value of almost any DICOM data element, regardless of the DicomVRType The Object can be any of the following:
This example shows how to set the value of various DICOM elements, regardless of the regardless of the DicomVRType or the multiplicity.
using Leadtools;
using Leadtools.Dicom;
///
private DicomElement MyInsertElement(DicomDataSet ds, long tag)
{
DicomTag myTag = DicomTagTable.Instance.Find(tag);
DicomElement element = ds.InsertElement(null, false, tag, myTag.VR, false, 0);
return element;
}
private void DicomDataSet_SetValueExample()
{
DicomElement element = null;
DicomDataSet ds = new DicomDataSet();
// Set a string
element = MyInsertElement(ds, DicomTag.PatientName);
ds.SetValue(element, "Joe^Patient");
// Set an array of strings
element = MyInsertElement(ds, DicomTag.OtherPatientNames);
string[] names = { "One", "Two", "Three" };
ds.SetValue(element, names);
// Another way to do an array of strings
List<string> it = new List<string>();
it.Add("ORIGINAL");
it.Add("PRIMARY");
element = MyInsertElement(ds, DicomTag.ImageType);
ds.SetValue(element, it.ToArray());
// Set an array of integers, that will be converted to strings
element = MyInsertElement(ds, DicomTag.PhysicianOfRecord);
int[] namesInt = { 1, 2, 3 };
ds.SetValue(element, namesInt);
// Set a DicomDateValue
element = MyInsertElement(ds, DicomTag.PatientBirthDate);
DicomDateValue dicomDate = new DicomDateValue(1961, 6, 5);
ds.SetValue(element, dicomDate);
// Set a DateTime
element = MyInsertElement(ds, DicomTag.InstanceCreationDate);
DateTime dateTime = new DateTime(2003, 5, 16);
ds.SetValue(element, dateTime);
// Set an array of DateTime
element = MyInsertElement(ds, DicomTag.DateOfLastCalibration);
DateTime[] dateTimeArray = { new DateTime(2000, 3, 8), new DateTime(2003, 5, 16) };
ds.SetValue(element, dateTimeArray);
ds.Save(Path.Combine(LEAD_VARS.ImagesDir, "test.dcm"), DicomDataSetSaveFlags.None);
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}
DicomDataSet.SetValue(DicomElement, object)
DicomDataSet.SetIntValue(DicomElement, int[], int)
DicomDataSet.SetShortValue(DicomElement, short[], int)
DicomDataSet.SetByteValue(DicomElement, Byte[], int)
DicomDataSet.SetBinaryValue(DicomElement, Byte[], int)
SetStringValue(DicomElement,string) Method
SetStringValue(DicomElement,string,DicomCharacterSetType) Method
SetStringValue(DicomElement,string[]) Method
SetStringValue(DicomElement,string[],DicomCharacterSetType) Method
SetStringValuePtr(DicomElement,IntPtr,int) Method
SetStringValuePtr(DicomElement,IntPtr,int,DicomCharacterSetType) Method
DicomDataSet.SetFloatValue(DicomElement, float[], int)
DicomDataSet.SetDoubleValue(DicomElement, double[], int)
SetDateValue(DicomElement,DicomDateValue[]) Method
SetTimeValue(DicomElement,DicomTimeValue[]) Method
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document