Esempio n. 1
0
 public void Clear()
 {
     _ms      = null;
     _br      = null;
     _bw      = null;
     _data    = null;
     _segment = null;
 }
Esempio n. 2
0
        public void Append(byte[] buffer, int offset, int count)
        {
            long pos = Stream.Position;

            Stream.Seek(0, SeekOrigin.End);
            Stream.Write(buffer, offset, count);
            Stream.Position = pos;
            _segment        = null;
        }
Esempio n. 3
0
        private ByteBuffer CurrentBuffer(DicomReadOptions options)
        {
#if SILVERLIGHT
            ByteBuffer bb = new ByteBuffer(_endian);
            bb.CopyFrom(_stream, (int)_len);
#else
            ByteBuffer bb = null;

            if (_isFile)
            {
                bool delayLoad = false;
                if (_len >= _largeElementSize && _vr != DicomVR.SQ)
                {
                    if (Flags.IsSet(options, DicomReadOptions.DeferLoadingLargeElements))
                    {
                        delayLoad = true;
                    }
                    else if (Flags.IsSet(options, DicomReadOptions.DeferLoadingPixelData) && _tag == DicomTags.PixelData)
                    {
                        delayLoad = true;
                    }
                    else if (Flags.IsSet(options, DicomReadOptions.DeferLoadingPixelData) && _fragment != null && _fragment.Tag == DicomTags.PixelData)
                    {
                        delayLoad = true;
                    }
                }

                if (delayLoad)
                {
                    FileStream  fs      = (FileStream)_stream;
                    FileSegment segment = new FileSegment(fs.Name, fs.Position, _len);
                    _stream.Seek(_len, SeekOrigin.Current);
                    bb = new ByteBuffer(segment, _endian);
                }
            }

            if (bb == null)
            {
                bb = new ByteBuffer(_endian);
                bb.CopyFrom(_stream, (int)_len);
            }
#endif
            if (_vr.IsEncodedString)
            {
                bb.Encoding = _encoding;
            }

            return(bb);
        }
Esempio n. 4
0
        public void Chop(int count)
        {
            _segment = null;
            int len = (int)Stream.Length;

            if (len <= count)
            {
                Stream.SetLength(0);
                return;
            }
            byte[] bytes = GetChunk(count, len - count);
            Stream.SetLength(0);
            Stream.Position = 0;
            Stream.Write(bytes, 0, bytes.Length);
        }
Esempio n. 5
0
        public void SetString(string val, byte pad)
        {
            int count = _encoding.GetByteCount(val);

            if ((count & 1) == 1)
            {
                count++;
            }

            byte[] bytes = new byte[count];
            if (_encoding.GetBytes(val, 0, val.Length, bytes, 0) < count)
            {
                bytes[count - 1] = pad;
            }

            _data    = bytes;
            _ms      = null;
            _segment = null;
        }
Esempio n. 6
0
        public int CopyFrom(Stream s, int count)
        {
            _ms      = null;
            _segment = null;
            _br      = null;
            _bw      = null;

            int read = 0;

            _data = new byte[count];

            while (read < count)
            {
                int rd = s.Read(_data, read, count - read);
                if (rd == 0)
                {
                    return(read);
                }
                read += rd;
            }

            return(read);
        }
Esempio n. 7
0
 public void FromBytes(byte[] bytes)
 {
     _data = bytes;
     _ms = null;
     _segment = null;
 }
Esempio n. 8
0
        public int CopyFrom(Stream s, int count)
        {
            _ms = null;
            _segment = null;
            _br = null;
            _bw = null;

            int read = 0;
            _data = new byte[count];

            while (read < count) {
                int rd = s.Read(_data, read, count - read);
                if (rd == 0)
                    return read;
                read += rd;
            }

            return read;
        }
Esempio n. 9
0
 public void Clear()
 {
     _ms = null;
     _br = null;
     _bw = null;
     _data = null;
     _segment = null;
 }
Esempio n. 10
0
 public void Chop(int count)
 {
     _segment = null;
     int len = (int)Stream.Length;
     if (len <= count) {
         Stream.SetLength(0);
         return;
     }
     byte[] bytes = GetChunk(count, len - count);
     Stream.SetLength(0);
     Stream.Position = 0;
     Stream.Write(bytes, 0, bytes.Length);
 }
Esempio n. 11
0
 public void Append(byte[] buffer, int offset, int count)
 {
     long pos = Stream.Position;
     Stream.Seek(0, SeekOrigin.End);
     Stream.Write(buffer, offset, count);
     Stream.Position = pos;
     _segment = null;
 }
Esempio n. 12
0
        private ByteBuffer CurrentBuffer(DicomReadOptions options)
        {
            ByteBuffer bb = null;

            if (_isFile) {
                bool delayLoad = false;
                if (_len >= _largeElementSize && _vr != DicomVR.SQ) {
                    if (Flags.IsSet(options, DicomReadOptions.DeferLoadingLargeElements))
                        delayLoad = true;
                    else if (Flags.IsSet(options, DicomReadOptions.DeferLoadingPixelData) && _tag == DicomTags.PixelData)
                        delayLoad = true;
                    else if (Flags.IsSet(options, DicomReadOptions.DeferLoadingPixelData) && _fragment != null && _fragment.Tag == DicomTags.PixelData)
                        delayLoad = true;
                }

                if (delayLoad) {
                    FileStream fs = (FileStream)_stream;
                    FileSegment segment = new FileSegment(fs.Name, fs.Position, _len);
                    _stream.Seek(_len, SeekOrigin.Current);
                    bb = new ByteBuffer(segment, _endian);
                }
            }

            if (bb == null) {
                bb = new ByteBuffer(_endian);
                bb.CopyFrom(_stream, (int)_len);
            }

            if (_vr.IsEncodedString)
                bb.Encoding = _encoding;

            return bb;
        }
Esempio n. 13
0
 public ByteBuffer(FileSegment segment)
     : this(segment, Endian.LocalMachine)
 {
 }
Esempio n. 14
0
 public void SetString(string val)
 {
     _data    = _encoding.GetBytes(val);
     _ms      = null;
     _segment = null;
 }
Esempio n. 15
0
 public void FromBytes(byte[] bytes)
 {
     _data    = bytes;
     _ms      = null;
     _segment = null;
 }
Esempio n. 16
0
 public void SetString(string val)
 {
     _data = _encoding.GetBytes(val);
     _ms = null;
     _segment = null;
 }
Esempio n. 17
0
        public void SetString(string val, byte pad)
        {
            int count = _encoding.GetByteCount(val);
            if ((count & 1) == 1)
                count++;

            byte[] bytes = new byte[count];
            if (_encoding.GetBytes(val, 0, val.Length, bytes, 0) < count)
                bytes[count - 1] = pad;

            _data = bytes;
            _ms = null;
            _segment = null;
        }
Esempio n. 18
0
 public ByteBuffer(FileSegment segment)
     : this(segment, Endian.LocalMachine)
 {
 }
Esempio n. 19
0
 public ByteBuffer(FileSegment segment, Endian endian)
 {
     _segment = segment;
     _endian = endian;
     _encoding = DcmEncoding.Default;
 }
Esempio n. 20
0
 public ByteBuffer(FileSegment segment, Endian endian)
 {
     _segment  = segment;
     _endian   = endian;
     _encoding = DcmEncoding.Default;
 }