Mercurial > hg > dmlib
comparison tests/efu.c @ 1444:5be4e2eec84f
Add dmSmoothMap() function to efu test.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 10 May 2018 04:39:34 +0300 |
parents | 985225a93aeb |
children | 60337b31e427 |
comparison
equal
deleted
inserted
replaced
1443:57e97e58cbf3 | 1444:5be4e2eec84f |
---|---|
274 | 274 |
275 lightMap[j][i] = vrayLen; | 275 lightMap[j][i] = vrayLen; |
276 } | 276 } |
277 } | 277 } |
278 | 278 |
279 #define Q_KERNEL(x, y, dist, coeff) ( \ | |
280 in[(y) - (dist)][(x)] * (coeff) + \ | |
281 in[(y) + (dist)][(x)] * (coeff) + \ | |
282 in[(y)][(x) - (dist)] * (coeff) + \ | |
283 in[(y)][(x) + (dist)] * (coeff) + \ | |
284 in[(y) - (dist)][(x) - (2)] * (coeff) + \ | |
285 in[(y) - (dist)][(x) + (2)] * (coeff) + \ | |
286 in[(y) + (dist)][(x) - (2)] * (coeff) + \ | |
287 in[(y) + (dist)][(x) + (2)] * (coeff)) | |
288 | |
289 #define Q_VALUES(coeff) (8 * (coeff)) | |
290 | |
291 void dmSmoothMap(DMBlockMap out, DMBlockMap in) | |
292 { | |
293 int x, y; | |
294 | |
295 for (y = 0; y < QHEIGHT; y++) | |
296 for (x = 0; x < QWIDTH; x++) | |
297 { | |
298 if (y >= 3 && x >= 3 && y < QHEIGHT - 3 && x < QWIDTH - 3) | |
299 out[y][x] = ( | |
300 Q_KERNEL(x, y, 3, 1) + | |
301 Q_KERNEL(x, y, 2, 2) + | |
302 Q_KERNEL(x, y, 1, 4) + | |
303 in[y][x] * 16) / | |
304 (16 + Q_VALUES(1) + Q_VALUES(2) + Q_VALUES(4)); | |
305 else | |
306 out[y][x] = in[y][x]; | |
307 } | |
308 } | |
279 | 309 |
280 int main(int argc, char *argv[]) | 310 int main(int argc, char *argv[]) |
281 { | 311 { |
282 SDL_Surface *screen = NULL, *bmap = NULL, *logo = NULL; | 312 SDL_Surface *screen = NULL, *bmap = NULL, *logo = NULL; |
283 TTF_Font *font = NULL; | 313 TTF_Font *font = NULL; |