LEADTOOLS Medical(Leadtools.Dicomアセンブリ)

フレームを表示

SetValueメソッド








データの項目は、設定しました。
>は、任意のサポートされた型でありえるObjectまたは任意のサポートされた型の配列です。
データ要素の値を設定します。値は、少しでもサポートされることができます型。
構文
public bool SetValue( 
   DicomElement element,
   object value
)
'Declaration
 
Public Function SetValue( _
   ByVal element As DicomElement, _
   ByVal value As Object _
) As Boolean
'Usage
 
Dim instance As DicomDataSet
Dim element As DicomElement
Dim value As Object
Dim value As Boolean
 
value = instance.SetValue(element, value)
public bool SetValue( 
   DicomElement element,
   object value
)
 function Leadtools.Dicom.DicomDataSet.SetValue( 
   element ,
   value 
)
public:
bool SetValue( 
   DicomElement^ element,
   Object^ value
) 

パラメーター

要素
データの項目は、設定しました。
>は、任意のサポートされた型でありえるObjectまたは任意のサポートされた型の配列です。

戻り値

オブジェクト値が正常に設定されるならばtrue。データ要素のオブジェクト値を設定することができないならば、間違った。
解説
注意:ユーザーは、メモリをに割り当てるために責任があります。

これはほとんど任意のDICOMデータ要素の値を設定するのに用いられることができる非常に柔軟な関数です、DicomVRTypeに関係なく、Objectは以下で任意でありえます:

サンプル

このサンプルは、DicomVRTypeを考えないものまたは多重度に関係なく、いろいろなDICOM要素の値を設定する方法を示します。

Copy Code  
Imports Leadtools
Imports Leadtools.Dicom

''' 
Private Function MyInsertElement(ByVal ds As DicomDataSet, ByVal tag As Long) As DicomElement
   Dim myTag As DicomTag = DicomTagTable.Instance.Find(tag)
   Dim element As DicomElement = ds.InsertElement(Nothing, False, tag, myTag.VR, False, 0)
   Return element
End Function
Private Sub DicomDataSet_SetValueExample()
   Dim element As DicomElement = Nothing
   Dim ds As DicomDataSet = 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)
   Dim names As String() = {"One", "Two", "Three"}
   ds.SetValue(element, names)

   ' Another way to do an array of strings
   Dim it As List(Of String) = New List(Of 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)
   Dim namesInt As Integer() = {1, 2, 3}
   ds.SetValue(element, namesInt)

   ' Set a DicomDateValue
   element = MyInsertElement(ds, DicomTag.PatientBirthDate)
   Dim dicomDate As DicomDateValue = New DicomDateValue(1961, 6, 5)
   ds.SetValue(element, dicomDate)

   ' Set a DateTime
   element = MyInsertElement(ds, DicomTag.InstanceCreationDate)
   Dim dateTime As DateTime = New DateTime(2003, 5, 16)
   ds.SetValue(element, dateTime)

   ' Set an array of DateTime
   element = MyInsertElement(ds, DicomTag.DateOfLastCalibration)
   Dim dateTimeArray As DateTime() = {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)
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
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:\Users\Public\Documents\LEADTOOLS Images";
}
using Leadtools.Dicom.Constants;
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 async Task DicomDataSet_SetValueExample()
{
   DicomElement element = null;
   DicomDataSet ds = new DicomDataSet();

   // Set a string
   element = MyInsertElement(ds, DicomTagConstants.PatientName);
   ds.SetValue(element, "Joe^Patient");

   // Set an array of strings
   element = MyInsertElement(ds, DicomTagConstants.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, DicomTagConstants.ImageType);
   ds.SetValue(element, it.ToArray());

   // Set an array of integers, that will be converted to strings
   element = MyInsertElement(ds, DicomTagConstants.PhysicianOfRecord);
   int[] namesInt = { 1, 2, 3 };
   ds.SetValue(element, namesInt);

   // Set a DicomDateValue
   element = MyInsertElement(ds, DicomTagConstants.PatientBirthDate);
   DicomDateValue dicomDate = DicomDateValueHelper.Create(1961, 6, 5);
   ds.SetValue(element, dicomDate);

   // Set a DateTime
   element = MyInsertElement(ds, DicomTagConstants.InstanceCreationDate);
   DateTime dateTime = new DateTime(2003, 5, 16);
   ds.SetValue(element, dateTime);

   // Set an array of DateTime
   element = MyInsertElement(ds, DicomTagConstants.DateOfLastCalibration);
   DateTime[] dateTimeArray = { new DateTime(2000, 3, 8), new DateTime(2003, 5, 16) };
   ds.SetValue(element, dateTimeArray);

   string dicomFileNameOutput = "test.dcm";
   StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(dicomFileNameOutput);
   ILeadStream streamOutput = LeadStreamFactory.Create(saveFile);
   using (IDisposable disposableOUT = streamOutput as IDisposable)
   {
      await ds.SaveAsync(streamOutput, DicomDataSetSaveFlags.None);
   }
}
using Leadtools;
using Leadtools.Dicom;
using Leadtools.Examples;

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(Stream outputStream)
{
   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(outputStream, DicomDataSetSaveFlags.None);
}
Imports Leadtools
Imports Leadtools.Dicom

Private Function MyInsertElement(ByVal ds As DicomDataSet, ByVal tag As Long) As DicomElement
   Dim myTag As DicomTag = DicomTagTable.Instance.Find(tag)
   Dim element As DicomElement = ds.InsertElement(Nothing, False, tag, myTag.VR, False, 0)
   Return element
End Function
Private Sub DicomDataSet_SetValueExample(ByVal outputStream As Stream)
   Dim element As DicomElement = Nothing
   Dim ds As DicomDataSet = 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)
   Dim names As String() = {"One", "Two", "Three"}
   ds.SetValue(element, names)

   ' Another way to do an array of strings
   Dim it As List(Of String) = New List(Of 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)
   Dim namesInt As Integer() = {1, 2, 3}
   ds.SetValue(element, namesInt)

   ' Set a DicomDateValue
   element = MyInsertElement(ds, DicomTag.PatientBirthDate)
   Dim dicomDate As DicomDateValue = New DicomDateValue(1961, 6, 5)
   ds.SetValue(element, dicomDate)

   ' Set a DateTime
   element = MyInsertElement(ds, DicomTag.InstanceCreationDate)
   Dim dateTime As DateTime = New DateTime(2003, 5, 16)
   ds.SetValue(element, dateTime)

   ' Set an array of DateTime
   element = MyInsertElement(ds, DicomTag.DateOfLastCalibration)
   Dim dateTimeArray As DateTime() = {New DateTime(2000, 3, 8), New DateTime(2003, 5, 16)}
   ds.SetValue(element, dateTimeArray)

   ds.Save(outputStream, DicomDataSetSaveFlags.None)
End Sub
必要条件

ターゲットプラットホーム

参照

参照

DicomDataSetクラス
DicomDataSetメンバ
DicomDataSet.SetValue(DicomElement、オブジェクト)
DicomDataSet.SetIntValue(DicomElement、int[]、int)
DicomDataSet.SetShortValue(DicomElement、略[]、int)
DicomDataSet.SetByteValue(DicomElement、Byte[]、int)
DicomDataSet.SetBinaryValue(DicomElement、Byte[]、int)
SetStringValue(DicomElement、String、DicomCharacterSetType)メソッド
SetStringValue(DicomElement、String[]、DicomCharacterSetType)メソッド
SetStringValue(DicomElement、String)メソッド
SetStringValue(DicomElement、String[])メソッド
SetStringValuePtr(DicomElement、IntPtr、Int32)メソッド
SetStringValuePtr(DicomElement、IntPtr、UInt32、DicomCharacterSetType)メソッド
DicomDataSet.SetFloatValue(DicomElement、フロート[]、int)
DicomDataSet.SetDoubleValue(DicomElement、倍[]、int)
SetAgeValueメソッド
SetDateValue(DicomElement、DicomDateValue[])メソッド
SetTimeValue(DicomElement、DicomTimeValue[])メソッド
SetDateTimeValue(DicomElement、DicomDateTimeValue[])メソッド
SetConvertValue(DicomElement、String、Int32)メソッド

Leadtools.Dicomは、Medicalツールキットサーバのライセンスと、解除キーが必要です。詳細は、以下を参照してください。Imaging Pro/Document/Medicalの機能