static void _image_orient(struct image *source, struct object *o[5], struct image *img[5]) { int i; struct { int x,y; } or[4]={ {1,0}, {1,1}, {0,1}, {-1,1} }; int x,y; for (i=0; i<5; i++) { push_int(source->xsize); push_int(source->ysize); o[i]=clone_object(image_program,2); img[i]=get_storage(o[i],image_program); push_object(o[i]); } THREADS_ALLOW(); CHRONO("start"); for (i=0; i<4; i++) /* four directions */ { rgb_group *d=img[i]->img; rgb_group *s=source->img; int xz=source->xsize; int yz=source->ysize; int xd=or[i].x; int yd=or[i].y; for(x=1; x<xz-1; x++) for(y=1; y<yz-1; y++) { #define FOOBAR(CO) \ d[x+y*xz].CO \ = \ (COLORTYPE) \ my_abs( s[(x+xd)+(y+yd)*xz].CO - s[(x-xd)+(y-yd)*xz].CO ) FOOBAR(r); FOOBAR(g); FOOBAR(b); #undef FOOBAR } } CHRONO("end"); THREADS_DISALLOW(); }
void bar() { foo(1, FOO); foo(1, FOOBAR(1,2)); foo(1, cp); }