diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-10-11 03:34:40 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-10-11 03:34:40 +0400 |
commit | 4a43099c5a61f302654b7f309572505894357227 (patch) | |
tree | 7863c7e2fd9a52d456ccb0b92f816d6f2e769729 /source/blender/imbuf | |
parent | 5f6d775e0c9247d2f5979670037ca5468ee67b40 (diff) |
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.
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/IMB_imbuf.h | 8 | ||||
-rw-r--r-- | source/blender/imbuf/intern/rotate.c | 26 |
2 files changed, 34 insertions, 0 deletions
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 @@ -418,6 +418,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)); + } + } + } +} |