private static DicomDataset ReadFragment(byte[] bytes, Endian endian, bool explicitVr)
 {
   var dataset = new DicomDataset();
   var reader = new DicomReader { IsExplicitVR = explicitVr };
   var byteSource = new ByteBufferByteSource(new MemoryByteBuffer(bytes)) { Endian = endian };
   reader.Read(byteSource, new DicomDatasetReaderObserver(dataset));
   return dataset;
 }
Example #2
0
		public FileByteTarget(FileReference file) {
			_file = file;
			_stream = _file.OpenWrite();
			_endian = Endian.LocalMachine;
			_writer = EndianBinaryWriter.Create(_stream, _endian);
			_lock = new object();
		}
 /// <summary>
 /// Initializes an instance of <see cref="StreamByteTarget"/>.
 /// </summary>
 /// <param name="stream">Stream subject to writing.</param>
 public StreamByteTarget(Stream stream)
 {
     _stream = stream;
     _endian = Endian.LocalMachine;
     _writer = EndianBinaryWriter.Create(_stream, _endian);
     _lock = new object();
 }
Example #4
0
 public DcmItem(DicomTag tag, DicomVR vr)
 {
     _tag = tag;
     _vr = vr;
     _streamPosition = 0;
     _endian = Endian.LocalMachine;
 }
Example #5
0
 public DcmItem(DicomTag tag, DicomVR vr, long pos, Endian endian)
 {
     _tag = tag;
     _vr = vr;
     _streamPosition = pos;
     _endian = endian;
 }
Example #6
0
		public DicomTransferSyntax(DicomUID uid, bool be, bool evr, bool encaps, bool lssy, bool dflt) {
			UID = uid;
			IsBigEndian = be;
			IsExplicitVR = evr;
			IsEncapsulated = encaps;
			IsLossy = lssy;
			IsDeflate = dflt;
			Endian = IsBigEndian ? Endian.Big : Endian.Little;
		}
Example #7
0
		public StreamByteSource(Stream stream) {
			_stream = stream;
			_endian = Endian.LocalMachine;
			_reader = EndianBinaryReader.Create(_stream, _endian);
			_mark = 0;

			_largeObjectSize = 64 * 1024;

			_milestones = new Stack<long>();
			_lock = new object();
		}
Example #8
0
		public FileByteSource(FileReference file) {
			_file = file;
			_stream = _file.OpenRead();
			_endian = Endian.LocalMachine;
			_reader = EndianBinaryReader.Create(_stream, _endian);
			_mark = 0;

			_largeObjectSize = 64 * 1024;

			_milestones = new Stack<long>();
			_lock = new object();
		}
Example #9
0
		public DcmItemSequence(DicomTag tag, long pos, uint length, Endian endian)
			: base(tag, DicomVR.SQ, pos, endian) {
			_streamLength = length;
		}
Example #10
0
 public ByteBuffer(Endian endian)
 {
     _endian   = endian;
     _encoding = DcmEncoding.Default;
 }
Example #11
0
 public EndianBinaryWriter(Stream output, Encoding encoding, Endian endian)
     : base(output, encoding)
 {
     Endian = endian;
 }
Example #12
0
        public static BinaryWriter Create(Stream output, Encoding encoding, Endian endian)
        {
            if (encoding == null)
                return Create(output, endian);
            if (output == null)
                throw new ArgumentNullException("output");
            if (endian == null)
                throw new ArgumentNullException("endian");

            if (BitConverter.IsLittleEndian) {
                if (Endian.Little == endian) {
                    return new BinaryWriter(output, encoding);
                }
                else {
                    return new EndianBinaryWriter(output, encoding, endian);
                }
            }
            else {
                if (Endian.Big == endian) {
                    return new BinaryWriter(output, encoding);
                }
                else {
                    return new EndianBinaryWriter(output, encoding, endian);
                }
            }
        }
Example #13
0
 public void Swap2()
 {
     Endian.SwapBytes2(ToBytes());
 }
Example #14
0
 public EndianBinaryReader(Stream input, Encoding encoding, Endian endian)
     : base(input, encoding)
 {
     Endian = endian;
 }
Example #15
0
 public void Swap(int bytesToSwap)
 {
     Endian.SwapBytes(bytesToSwap, ToBytes());
 }
Example #16
0
 internal void SelectByteOrder(Endian endian)
 {
     foreach (DcmItem item in _items.Values) {
         item.Endian = endian;
     }
 }
Example #17
0
 public ByteBuffer(byte[] data, Endian endian)
 {
     _data     = data;
     _endian   = endian;
     _encoding = DcmEncoding.Default;
 }
Example #18
0
 public ByteBuffer(byte[] data, Endian endian)
 {
     _data = data;
     _endian = endian;
     _encoding = DcmEncoding.Default;
 }
Example #19
0
 public ByteBuffer(FileSegment segment, Endian endian)
 {
     _segment  = segment;
     _endian   = endian;
     _encoding = DcmEncoding.Default;
 }
Example #20
0
 public EndianBinaryWriter(Stream output, Encoding encoding, Endian endian)
     : base(output, encoding)
 {
     Endian = endian;
 }
Example #21
0
 public EndianBinaryWriter(Stream output, Endian endian)
     : base(output)
 {
     Endian = endian;
 }
Example #22
0
 public DcmFragmentSequence(DicomTag tag, DicomVR vr, long pos, Endian endian)
     : base(tag, vr, pos, endian)
 {
 }
Example #23
0
 public EndianBinaryReader(Stream input, Encoding encoding, Endian endian)
     : base(input, encoding)
 {
     Endian = endian;
 }
Example #24
0
 public void Swap8()
 {
     Endian.SwapBytes8(ToBytes());
 }
Example #25
0
        public static BinaryReader Create(Stream input, Endian endian)
        {
            if (input == null)
                throw new ArgumentNullException("input");
            if (endian == null)
                throw new ArgumentNullException("endian");

            if (BitConverter.IsLittleEndian) {
                if (Endian.Little == endian) {
                    return new BinaryReader(input);
                } else {
                    return new EndianBinaryReader(input, endian);
                }
            } else {
                if (Endian.Big == endian) {
                    return new BinaryReader(input);
                } else {
                    return new EndianBinaryReader(input, endian);
                }
            }
        }
Example #26
0
 public void Swap4()
 {
     Endian.SwapBytes4(ToBytes());
 }
Example #27
0
 public EndianBinaryWriter(Stream output, Endian endian)
     : base(output)
 {
     Endian = endian;
 }
Example #28
0
 public ByteBuffer(Endian endian)
 {
     _endian = endian;
     _encoding = DcmEncoding.Default;
 }
Example #29
0
 public EndianBinaryReader(Stream input, Endian endian)
     : base(input)
 {
     Endian = endian;
 }
Example #30
0
 public ByteBuffer(FileSegment segment, Endian endian)
 {
     _segment = segment;
     _endian = endian;
     _encoding = DcmEncoding.Default;
 }
Example #31
0
 public EndianBinaryReader(Stream input, Endian endian)
     : base(input)
 {
     Endian = endian;
 }