Ejemplo n.º 1
0
        /// <summary>
        /// Reads and returns the next DICOM element starting at the current location in the DICOM binary reader
        /// </summary>
        /// <param name="dr">the binary reader which is reading the DICOM object</param>
        /// <returns>the next DICOM element</returns>
        public static IDICOMElement ReadElementExplicitLittleEndian(DICOMBinaryReader dr)
        {
            Tag tag = TagReader.ReadLittleEndian(dr);
            VR  vr  = VRReader.ReadVR(dr);

            return(ReadElementExplicitLittleEndian(tag, vr, dr));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads and returns the next DICOM element starting at the current location in the DICOM binary reader
        /// </summary>
        /// <param name="dr">the binary reader which is reading the DICOM object</param>
        /// <returns>the next DICOM element</returns>
        public static IDICOMElement ReadElementExplicitLittleEndian(DICOMBinaryReader dr, StringEncoding enc = StringEncoding.ISO_IR_192)
        {
            var tag = TagReader.ReadLittleEndian(dr);
            var vr  = VRReader.ReadVR(dr);

            return(ReadElementExplicitLittleEndian(tag, vr, dr, enc));
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Reads and returns the next DICOM element starting at the current location in the DICOM binary reader
        /// </summary>
        /// <param name="dr">the binary reader which is reading the DICOM object</param>
        /// <returns>the next DICOM element</returns>
        public static IDICOMElement ReadElementExplicitBigEndian(DICOMBinaryReader dr, StringEncoding enc)
        {
            var tag    = TagReader.ReadBigEndian(dr);
            var vr     = VRReader.ReadVR(dr);
            var length = LengthReader.ReadBigEndian(vr, dr);
            var data   = DataReader.ReadBigEndian(length, dr);

            return(ElementFactory.GenerateElement(tag, vr, data, TransferSyntax.EXPLICIT_VR_BIG_ENDIAN, enc));
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Reads and returns the next DICOM element starting at the current location in the DICOM binary reader
        /// </summary>
        /// <param name="dr">the binary reader which is reading the DICOM object</param>
        /// <returns>the next DICOM element</returns>
        public static IDICOMElement ReadElementExplicitBigEndian(DICOMBinaryReader dr)
        {
            Tag tag    = TagReader.ReadBigEndian(dr);
            VR  vr     = VRReader.ReadVR(dr);
            int length = LengthReader.ReadBigEndian(vr, dr);

            byte[] data = DataReader.ReadBigEndian(length, dr);
            return(ElementFactory.GenerateElement(tag, vr, data, TransferSyntax.EXPLICIT_VR_BIG_ENDIAN));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Reads and returns the next DICOM element starting at the current location in the DICOM binary reader
        /// </summary>
        /// <param name="dr">the binary reader which is reading the DICOM object</param>
        /// <returns>the next DICOM element</returns>
        public static IDICOMElement ReadElementExplicitLittleEndian(DICOMBinaryReader dr)
        {
            var tag    = TagReader.ReadLittleEndian(dr);
            var vr     = VRReader.Read(dr);
            int length = LengthReader.ReadLittleEndian(vr, dr);
            var data   = DataReader.ReadLittleEndian(length, dr, TransferSyntax.EXPLICIT_VR_LITTLE_ENDIAN);

            return(ElementFactory.GenerateElement(tag, vr, data, TransferSyntax.EXPLICIT_VR_LITTLE_ENDIAN));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// This method helps read non-compliant files. Sometimes, an supposed implicit is encoded explicitly. We'll check here
 /// Returns true if element is actually encoded explicitly (VR is written as starting characters).
 /// </summary>
 /// <param name="tag">the read tag</param>
 /// <param name="dr">the binary reader which is reading the DICOM object</param>
 /// <param name="vr">the determined VR from the tag</param>
 /// <returns></returns>
 private static bool CheckForExplicitness(Tag tag, DICOMBinaryReader dr, ref VR vr)
 {
     if (VRReader.PeekVR(dr) != VR.Null)
     {
         vr = VRReader.ReadVR(dr);
         Logging.EvilLogger.Instance.Log($"{tag} was expectd to be implicit LE but is explicit LE. Attempting to read...");
         return(true);
     }
     //Implicilty encoded - All is well
     return(false);
 }
Ejemplo n.º 7
0
        public static void SkipElementExplicitBigEndian(DICOMBinaryReader dr)
        {
            var tag    = TagReader.ReadBigEndian(dr);
            var vr     = VRReader.ReadVR(dr);
            var length = LengthReader.ReadBigEndian(vr, dr);

            if (length != -1)
            {
                dr.Skip(length);
            }
            else
            {
                dr.Skip(SequenceReader.ReadIndefiniteLengthBigEndian(dr));
                dr.Skip(8);
            }
        }
Ejemplo n.º 8
0
        public static void SkipElementExplicitLittleEndian(DICOMBinaryReader dr)
        {
            var tag    = TagReader.ReadLittleEndian(dr);
            var vr     = VRReader.ReadVR(dr);
            var length = LengthReader.ReadLittleEndian(vr, dr);

            if (length != -1)
            {
                dr.Skip(length);
            }
            else
            {
                dr.Skip(SequenceReader.ReadIndefiniteLengthLittleEndian(dr, TransferSyntax.EXPLICIT_VR_LITTLE_ENDIAN));
                dr.Skip(8);
            }
        }