|
楼主 |
发表于 2024-10-31 09:16:14
|
显示全部楼层
#include <cmath>
#include <omp.h>
bool CLayerLocatePro_Updata::ProcessInterpolate(const BYTE *pImage, int nWidth, int nHeight,
const RLE_DATA *pRLE, int nCount,
double fShiftX, double fShiftY, BYTE *pDestImg) {
#pragma omp parallel for // OpenMP并行化
for (int j = 0; j < nHeight; ++j) {
for (int i = 0; i < nWidth; ++i) {
int nx = (int)floor(fShiftX);
int ny = (int)floor(fShiftY);
double dx = fShiftX - (double)nx;
double dy = fShiftY - (double)ny;
double coef11 = (1 - dx) * (1 - dy);
double coef12 = (1 - dx) * dy;
double coef21 = dx * (1 - dy);
double coef22 = dx * dy;
// 确保像素索引不越界
if (j + ny + 1 < nHeight && i + nx + 1 < nWidth) {
pDestImg[j * nWidth + i] = (BYTE)(
pImage[(j + ny) * nWidth + i + nx] * coef11 +
pImage[(j + ny + 1) * nWidth + i + nx] * coef12 +
pImage[(j + ny) * nWidth + i + nx + 1] * coef21 +
pImage[(j + ny + 1) * nWidth + i + nx + 1] * coef22
);
}
}
}
return true;
}
|
|