示例#1
0
 public void Clear()
 {
     _ms      = null;
     _br      = null;
     _bw      = null;
     _data    = null;
     _segment = null;
 }
示例#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;
        }
示例#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);
        }
示例#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);
        }
示例#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;
        }
示例#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);
        }
示例#7
0
 public void FromBytes(byte[] bytes)
 {
     _data = bytes;
     _ms = null;
     _segment = null;
 }
示例#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;
        }
示例#9
0
 public void Clear()
 {
     _ms = null;
     _br = null;
     _bw = null;
     _data = null;
     _segment = null;
 }
示例#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);
 }
示例#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;
 }
示例#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;
        }
示例#13
0
 public ByteBuffer(FileSegment segment)
     : this(segment, Endian.LocalMachine)
 {
 }
示例#14
0
 public void SetString(string val)
 {
     _data    = _encoding.GetBytes(val);
     _ms      = null;
     _segment = null;
 }
示例#15
0
 public void FromBytes(byte[] bytes)
 {
     _data    = bytes;
     _ms      = null;
     _segment = null;
 }
示例#16
0
 public void SetString(string val)
 {
     _data = _encoding.GetBytes(val);
     _ms = null;
     _segment = null;
 }
示例#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;
        }
示例#18
0
 public ByteBuffer(FileSegment segment)
     : this(segment, Endian.LocalMachine)
 {
 }
示例#19
0
 public ByteBuffer(FileSegment segment, Endian endian)
 {
     _segment = segment;
     _endian = endian;
     _encoding = DcmEncoding.Default;
 }
示例#20
0
 public ByteBuffer(FileSegment segment, Endian endian)
 {
     _segment  = segment;
     _endian   = endian;
     _encoding = DcmEncoding.Default;
 }