diff options
author | Peter Schlaile <peter@schlaile.de> | 2007-10-12 10:37:20 +0400 |
---|---|---|
committer | Peter Schlaile <peter@schlaile.de> | 2007-10-12 10:37:20 +0400 |
commit | 3697e0852467a29223a59d2ad6a31a00cfbde529 (patch) | |
tree | 8c86485c60cd49e2080d90d1d904e2000f5e7d72 /source/blender/imbuf | |
parent | 4f961081377ce262823fd4a037ce969fc5088474 (diff) |
== IMBuf fix ==
Fixed Campbell's patch for IMB_flipx:
- header file declaration is corrected
- reordered loops to make things faster (less cache misses
and no tests for float-buffers on a _per pixel basis_!)
(Campbell: it'd be nice, if you could check with me before patching
the sequencer. Or at least pay attention to compiler warnings :) )
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/IMB_imbuf.h | 9 | ||||
-rw-r--r-- | source/blender/imbuf/intern/rotate.c | 22 |
2 files changed, 15 insertions, 16 deletions
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 11cdebe70c3..2ca21e548c4 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -418,14 +418,6 @@ 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 */ @@ -532,6 +524,7 @@ extern float rgb_to_bw[4][4]; * * @attention Defined in rotate.c */ +void IMB_flipx(struct ImBuf *ibuf); void IMB_flipy(struct ImBuf * ibuf); /** diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c index 4654dd6aefa..42b30d6284f 100644 --- a/source/blender/imbuf/intern/rotate.c +++ b/source/blender/imbuf/intern/rotate.c @@ -94,17 +94,23 @@ void IMB_flipx(struct ImBuf * ibuf) 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) { + + if (ibuf->rect) { + 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) { + for(yi=y-1;yi>=0;yi--) { + for(xr=x-1, xl=0; xr>=xl; xr--, xl++) { 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)); |