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/IMB_imbuf.h | 8 ++++++++ source/blender/imbuf/intern/rotate.c | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) (limited to 'source/blender/imbuf') diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index e56fb5a776d..11cdebe70c3 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -417,6 +417,14 @@ void bilinear_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float */ void IMB_convert_bgra_to_rgba(int size, unsigned int *rect); +/** + * Flip the image X/Y + * + * @attention Defined in imageprocess.c + */ +void IMB_xflip(struct ImBuf *ibuf); +void IMB_yflip(struct ImBuf *ibuf); + /** * * @attention defined in scaling.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