CopyFrom() public method

public CopyFrom ( Stream s, int count ) : int
s Stream
count int
return int
Example #1
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);
        }
Example #2
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;
        }