diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-02-23 17:51:01 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-02-23 17:51:30 +0300 |
commit | 041f706506da3962e6c03fcf2a4227afd678dca0 (patch) | |
tree | 0affe06ec35a28fbb2cf3f357f101abbfebe376a /source/blender/imbuf/intern | |
parent | eacc3debb75f1eed9777194773f2cab398c48d17 (diff) |
IMB library: Add function that scales an array of byte or float pixels.
Function just wraps the array in an imbuf and does regular imbuf
scaling.
Diffstat (limited to 'source/blender/imbuf/intern')
-rw-r--r-- | source/blender/imbuf/intern/scaling.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index 2601fe62c2f..f2731e5decf 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -1545,6 +1545,39 @@ struct ImBuf *IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int return(ibuf); } +struct ImBuf *IMB_scaleArray(const unsigned int *rect, const float *frect, + unsigned int oldw, unsigned int oldh, + unsigned int neww, unsigned int newh) +{ + ImBuf *ibuf = NULL; + ImBuf *tmpibuf = IMB_allocImBuf(oldw, oldh, 32, 0); + + if (frect) { + /* allocate new image buffer and set the temporary buffer float buffer correctly */ + ibuf = IMB_allocImBuf(oldw, oldh, 32, IB_rectfloat); + tmpibuf->rect_float = (float *)frect; + + IMB_rectcpy(ibuf, tmpibuf, 0, 0, 0, 0, oldw, oldh); + + IMB_scaleImBuf(ibuf, neww, newh); + } + else if (rect) { + ibuf = IMB_allocImBuf(oldw, oldh, 32, IB_rect); + tmpibuf->rect = (unsigned int *)rect; + + IMB_rectcpy(ibuf, tmpibuf, 0, 0, 0, 0, oldw, oldh); + + IMB_scaleImBuf(ibuf, neww, newh); + } + + /* important, else we clean the source image imbufs! */ + tmpibuf->rect_float = NULL; + tmpibuf->rect = NULL; + IMB_freeImBuf(tmpibuf); + + return ibuf; +} + struct imbufRGBA { float r, g, b, a; }; |