其中关键函数是将输入的 pSrcBits数组利用游程编码进行压缩,输出结果数组pRLEBits。需要注意的是判断当前指针是否处在行末的位置。 函数体中有state_start;state_compress;state_no_compress;end_of_line四个状态。 void CDVDBitmapControl::CompressInRLE8(BYTE* pSrcBits, CByteArray& pRLEBits, int& RLE_size) { int line; int src_index = 0, dst_index = 0, counter, i; // in RLE8 every pixel is one byte for ( line = 0; line < m_dib.dsBmih.biHeight; line++) { state_start: // just at the start of a block if ( EndOfLine(src_index)) // this is the last pixel of the line { pRLEBits[dst_index++] = 1; // block of length 1 pRLEBits[dst_index++] = pSrcBits[src_index]; src_index++; goto end_of_line; } // now the block length is at least 2, look ahead to decide next state // next two same pixels are the same, enter compress mode if (pSrcBits[src_index] == pSrcBits[src_index+1]) goto state_compress; if ( EndOfLine(src_index+1)) // the last 2 pixel of the line { // these 2 pi
RLE-BMP 利用一维行程编码压缩8位BMP
最新推荐文章于 2022-06-11 09:49:08 发布