From 4a43099c5a61f302654b7f309572505894357227 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 10 Oct 2007 23:34:40 +0000 Subject: Peach request new option for the image sequencer's image strips, flip x/y, (useful when making animatics to test the direction characters walk across the screen) added IMB_flipy was alredy there, needed to add IMB_flipx. --- source/blender/imbuf/intern/rotate.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source/blender/imbuf/intern/rotate.c') diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c index 13edfbf0a33..4654dd6aefa 100644 --- a/source/blender/imbuf/intern/rotate.c +++ b/source/blender/imbuf/intern/rotate.c @@ -86,3 +86,29 @@ void IMB_flipy(struct ImBuf * ibuf) MEM_freeN(line); if(linef) MEM_freeN(linef); } + +void IMB_flipx(struct ImBuf * ibuf) +{ + short x, y, xr, xl, yi; + unsigned int px; + float px_f[4]; + + if (ibuf == NULL) return; + if (ibuf->rect == NULL) return; + + x = ibuf->x; + y = ibuf->y; + for(yi=y-1;yi>=0;yi--) { + for(xr=x-1, xl=0; xr>=xl; xr--, xl++) { + px = ibuf->rect[(x*yi)+xr]; + ibuf->rect[(x*yi)+xr] = ibuf->rect[(x*yi)+xl]; + ibuf->rect[(x*yi)+xl] = px; + + if (ibuf->rect_float) { + memcpy(&px_f, &ibuf->rect_float[((x*yi)+xr)*4], 4*sizeof(float)); + memcpy(&ibuf->rect_float[((x*yi)+xr)*4], &ibuf->rect_float[((x*yi)+xl)*4], 4*sizeof(float)); + memcpy(&ibuf->rect_float[((x*yi)+xl)*4], &px_f, 4*sizeof(float)); + } + } + } +} -- cgit v1.2.3