/* * FLOATIMG * distorsions géométriques - coredumping ? */ #include #include #include "../floatimg.h" /* --------------------------------------------------------------------- */ /* * really crude function, need more work... */ int fimg_halfsize_0(FloatImg *src, FloatImg *dst, int notused) { int wd, hd; int foo, x, y; float pixel[3]; #if DEBUG_LEVEL fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, notused); #endif /* no magic check here ? */ if (dst->width || dst->height) { fprintf(stderr, "*** %s: image at %p not empty\n", __func__, dst); fimg_describe(dst, "destination halfsize 0"); return -2; } wd = src->width / 2; hd = src->height / 2; foo = fimg_create(dst, wd, hd, FIMG_TYPE_RGB); if (foo) { fprintf(stderr, "%s: err create %d\n", __func__, foo); return -3; } for (y=0; ywidth || dst->height) { fprintf(stderr, "*** %s: image at %p not empty\n", __func__, dst); fimg_describe(dst, "destination halfsize 1"); return -2; } wd = src->width / 2; hd = src->height / 2; if ( (foo = fimg_create(dst, wd, hd, FIMG_TYPE_RGB)) ) { fprintf(stderr, "%s: err create %d\n", __func__, foo); return -3; } #define WS (src->width) #define WD (dst->width) for (y=0; yR[(y2*WS)+x2] + src->R[(y2*WS)+x2+1] + src->R[((1+y2)*WS)+x2] + src->R[((1+y2)*WS)+x2+1]; dst->R[y*WD +x] = ac / 4.0; ac = src->G[(y2*WS)+x2] + src->G[(y2*WS)+x2+1] + src->G[((1+y2)*WS)+x2] + src->G[((1+y2)*WS)+x2+1]; dst->G[y*WD +x] = ac / 4.0; ac = src->B[(y2*WS)+x2] + src->B[(y2*WS)+x2+1] + src->B[((1+y2)*WS)+x2] + src->B[((1+y2)*WS)+x2+1]; dst->B[y*WD +x] = ac / 4.0; } } #undef WS #undef WD return 0; } /* --------------------------------------------------------------------- */