工程中需要简单的马赛克算法模糊,看到网上的一些易读性不强,所以按自己的理解写了一个,调用了FreeImage的API,不过修改为直接操作BITMAP即可.
针对边界还没有完善,后面会再回头完善一下
DWORD mosaic_size = 12; // 默认12
auto w = FreeImage_GetWidth(dibMosaic);
auto h = FreeImage_GetHeight(dibMosaic);
DWORD max_grid_x = ceil(w * 1.0 / mosaic_size);
DWORD max_grid_y = ceil(h * 1.0 / mosaic_size);
DWORD max_grid_xy = max_grid_x * max_grid_y;
DWORD* sum_r = new DWORD[max_grid_xy];
DWORD* sum_g = new DWORD[max_grid_xy];
DWORD* sum_b = new DWORD[max_grid_xy];
DWORD* sum_a = new DWORD[max_grid_xy];
memset(sum_r, 0, sizeof(DWORD)*max_grid_xy);
memset(sum_g, 0, sizeof(DWORD)*max_grid_xy);
memset(sum_b, 0, sizeof(DWORD)*max_grid_xy);
memset(sum_b, 0, sizeof(DWORD)*max_grid_xy);