using System;
using System.Collections;
using System.Linq;
using System.Text;
namespace Bitmap2Code
{
class RLE_Compress
{
///
/// кодирует входной список методом RLE
///
///
/// OutBitmapList
public static ArrayList CompressRLE(ArrayList InBitmapList)
{
ArrayList OutBitmapList = new ArrayList();
uint[] InBitmapArray = new uint[InBitmapList.Count];
long indxIN = InBitmapList.Count - 1;
long repeatBytesVal = 1;
long NONrepeatBytesVal = 0;
uint i = 0;
InBitmapList.CopyTo(InBitmapArray);
uint repeatByte1 = InBitmapArray[0];
uint repeatByte2 = InBitmapArray[1];
for(i=0;i 0)
{
OutBitmapList.Add((uint)NONrepeatBytesVal);
for (long j = NONrepeatBytesVal; j >0; j--) //Запись в выходной массив всех не повторяющихся точек
{
OutBitmapList.Add(InBitmapArray[i-(2*j-1)]);
OutBitmapList.Add(InBitmapArray[i - (2 * j )]);
}
}
repeatByte1=InBitmapArray[i];
repeatByte2 = InBitmapArray[i+1 ];
i -= 2;
NONrepeatBytesVal = 0;
repeatBytesVal = 1;
}
return OutBitmapList;
}
}
}