Ejemplo n.º 1
0
 internal override void Read(byte[] buffer)
 {
     var rleStream = new MemoryStream(rleData);
     var rleReader = new RleReader(rleStream);
     var bufferIndex = 0;
     for (int i = 0; i < Size.Height; i++)
     {
         var bytesRead = rleReader.Read(buffer, bufferIndex, BytesPerRow);
         if (bytesRead != BytesPerRow)
         {
             throw new Exception("RLE row decompressed to unexpected length.");
         }
         bufferIndex += bytesRead;
     }
 }
Ejemplo n.º 2
0
        private byte[] DecodeRleData(byte[] rleData, int[] dataLengths)
        {
            var totalDataLength = dataLengths.Sum();
            var data            = new byte[totalDataLength];

            var rleStream = new MemoryStream(rleData);
            var rleReader = new RleReader(rleStream);

            int offset = 0;

            for (int i = 0; i < dataLengths.Length; i++)
            {
                var count = dataLengths[i];
                rleReader.Read(data, offset, count);
                offset += count;
            }

            return(data);
        }