Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.3.25
|
Leadtools.Dicom Namespace > DicomElement Class : Offset Property |
public long Offset {get;}
'Declaration
Public ReadOnly Property Offset As Long
'Usage
Dim instance As DicomElement Dim value As Long value = instance.Offset
public long Offset {get;}
get_Offset();
This example displays information about each element in a DicomDataSet including: * Tag * Name * Offset * Value offset * Value length
Imports Leadtools Imports Leadtools.Dicom ''' Private Sub DicomDataSetOffsetTest(ByVal ds As DicomDataSet) Dim element As DicomElement = ds.GetFirstElement(Nothing, False, True) Do While element IsNot Nothing DumpElementValue(element) element = ds.GetNextElement(element, False, True) Loop End Sub Private Sub DumpElementValue(ByVal element As DicomElement) Dim tag As DicomTag = DicomTagTable.Instance.Find(element.Tag) Dim name As String = String.Empty If tag IsNot Nothing Then name = tag.Name End If Console.WriteLine("{0} {1,-30} 0x{2:X8} 0x{3:X8} {4}", GetElementString(element), Truncate(name, 30), element.Offset, element.ValueOffset, element.ValueLength) End Sub Private Function GetElementString(ByVal p As DicomElement) As String If p Is Nothing Then Return String.Empty End If Return String.Format("({0:X4},{1:X4})", p.Tag >> &H10, p.Tag And &HFFFF) End Function Private Function Truncate(ByVal s As String, ByVal length As Integer) As String If s.Length > length Then Return s.Substring(0, length) End If Return s End Function
using Leadtools; using Leadtools.Dicom; /// private void DicomDataSetOffsetTest(DicomDataSet ds) { DicomElement element = ds.GetFirstElement(null, false, true); while (element != null) { DumpElementValue(element); element = ds.GetNextElement(element, false, true); } } private string GetElementString(DicomElement p) { if (p == null) return string.Empty; return string.Format("({0:X4},{1:X4})", p.Tag >> 0x10, p.Tag & 0xFFFF); } private string Truncate(string s, int length) { if (s.Length > length) return s.Substring(0, length); return s; } private void DumpElementValue(DicomElement element) { DicomTag tag = DicomTagTable.Instance.Find(element.Tag); string name = string.Empty; if (tag != null) { name = tag.Name; } Console.WriteLine(@"{0} {1,-30} 0x{2:X8} 0x{3:X8} {4}", GetElementString(element), Truncate(name, 30), element.Offset, element.ValueOffset, element.ValueLength); }