//传入滤波窗口系数和尺寸(nSize*nSize) void CxBitmap::Filter(double* pfFactors, int nSize, BOOL bAve) { double fMedian = 0; int nRead = 0; int nRadius = nSize / 2;//滤波窗口的半径 int nBytePerPixel = bitmapinfoheader.biBitCount / 8; int i, j, k, m, n;
//拷贝边界到临时缓存区 for (i = 0; i < nRadius; ++i) { memcpy(pbyTmpBuffer + i * m_nBytesPerLine, pbyBuffer + i * m_nBytesPerLine, m_nBytesPerLine); memcpy(pbyTmpBuffer + (bitmapinfoheader.biHeight - 1 - i) * m_nBytesPerLine, pbyBuffer + (bitmapinfoheader.biHeight - 1 - i) * m_nBytesPerLine, m_nBytesPerLine); }
for (i = 0; i < bitmapinfoheader.biHeight; ++i) { nRead = i * m_nBytesPerLine; for (j = 0; j < nRadius; ++j) { pbyTmpBuffer[nRead] = pbyBuffer[nRead++]; pbyTmpBuffer[nRead] = pbyBuffer[nRead++]; pbyTmpBuffer[nRead] = pbyBuffer[nRead++]; }