[Bf-blender-cvs] [041f706] master: IMB library: Add function that scales an array of byte or float pixels.
Antony Riakiotakis
noreply at git.blender.org
Mon Feb 23 15:59:28 CET 2015
Commit: 041f706506da3962e6c03fcf2a4227afd678dca0
Author: Antony Riakiotakis
Date: Mon Feb 23 15:51:01 2015 +0100
Branches: master
https://developer.blender.org/rB041f706506da3962e6c03fcf2a4227afd678dca0
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.
===================================================================
M source/blender/imbuf/IMB_imbuf.h
M source/blender/imbuf/intern/scaling.c
===================================================================
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 17bb873..27cb934 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -353,6 +353,14 @@ struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1);
struct ImBuf *IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy);
/**
+ * Scales an array of pixels and returns the result to a new ImBuf
+ * \attention Defined in scaling.c
+ */
+struct ImBuf *IMB_scaleArray(const unsigned int *rect, const float *frect,
+ unsigned int oldw, unsigned int oldh,
+ unsigned int neww, unsigned int newh);
+
+/**
*
* \attention Defined in scaling.c
*/
diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c
index 2601fe6..f2731e5 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;
};
More information about the Bf-blender-cvs
mailing list