Ejemplo n.º 1
0
        private void ReadTagVRLength()
        {
            if (CurrentTag != DicomTag.Undefined)
            {
                throw new InvalidOperationException($"Reading of {CurrentTag} not completed");
            }

            CurrentTag = DicomTag.ReadFrom(DataReader);

            if (CurrentTag.GroupNumber == 0xFFFF)
            {
                throw new IOException($"Invalid DICOM tag {CurrentTag} in input"); // See part 5, section 7.5.1 Item Encoding Rules
            }

            if (CurrentTag.HasVR && (VRCoding == DicomVRCoding.Explicit))
            {
                DataReader.Read(out byte b0);
                DataReader.Read(out byte b1);
                var id = new ValueTuple <byte, byte>(b0, b1);
                ExplicitVR = DicomVR.Lookup(id);
                if (ExplicitVR is IHas16BitExplicitVRLength)
                {
                    ValueLength = DataReader.Read <UInt16>();
                }
                else
                {
                    Input.SkipBytes(2);
                    ValueLength = DataReader.Read <UInt32>();
                }
            }
            else
            {
                ValueLength = DataReader.Read <UInt32>();
                if (CurrentTag.IsDelimitationItem && (ValueLength != 0))
                {
                    throw new IOException($"Expected 0 length for {CurrentTag} but got {ValueLength}");
                }
            }
        }
 /// <summary>Maps a property to a DICOM attribute</summary>
 public DicomAttributeAttribute(ushort groupNumber, ushort elementNumber, string vr)
 {
     Tag = new DicomTag(groupNumber, elementNumber);
     VR  = DicomVR.Lookup(vr);
 }