indi6748 / mdcm

Automatically exported from code.google.com/p/mdcm
0 stars 0 forks source link

Rle decoder constructor requires stream rewind to read rle header info #11

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. initialzing the rledecoder class

What is the expected output? What do you see instead?
Expected output is the segment count and segment offsets

What version of the product are you using? On what operating system?
latest dicom codec codes win xp

Please provide any additional information below.

A simple fix (see inserted line  'stream.Position = 0;' shown below)

  #region Public Constructors
            public RLEDecoder(IList<ByteBuffer> data)
            {
                int size = 0;
                foreach (ByteBuffer frag in data)
                    size += frag.Length;
                MemoryStream stream = new MemoryStream(size);
                foreach (ByteBuffer frag in data)
                    frag.CopyTo(stream);
                BinaryReader reader = EndianBinaryReader.Create(stream, Endian.Little);
                stream.Position = 0;
                _count = (int)reader.ReadUInt32();
                _offsets = new int[15];
                for (int i = 0; i < 15; i++)
                {
                    _offsets[i] = reader.ReadInt32();
                }
                _data = new byte[stream.Length - 64]; // take off 64 bytes for the offsets
                stream.Read(_data, 0, _data.Length);
            }
            #endregion

Original issue reported on code.google.com by Ed.Mar...@Cardio.chboston.org on 25 Jun 2010 at 3:08