After discussion on irc change new function to only allocate from a

buffer only. scaling can be done separately
This commit is contained in:
Antony Riakiotakis
2015-02-23 16:30:37 +01:00
parent 041f706506
commit 1940cf5a0b
2 changed files with 10 additions and 16 deletions

View File

@@ -353,12 +353,11 @@ 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
* Create a copy of a pixel buffer and wrap it 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);
struct ImBuf *IMB_allocFromBuffer(const unsigned int *rect, const float *frect,
unsigned int w, unsigned int h);
/**
*

View File

@@ -1545,29 +1545,24 @@ 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)
struct ImBuf *IMB_allocFromBuffer(const unsigned int *rect, const float *frect,
unsigned int w, unsigned int h)
{
ImBuf *ibuf = NULL;
ImBuf *tmpibuf = IMB_allocImBuf(oldw, oldh, 32, 0);
ImBuf *tmpibuf = IMB_allocImBuf(w, h, 32, 0);
if (frect) {
/* allocate new image buffer and set the temporary buffer float buffer correctly */
ibuf = IMB_allocImBuf(oldw, oldh, 32, IB_rectfloat);
ibuf = IMB_allocImBuf(w, h, 32, IB_rectfloat);
tmpibuf->rect_float = (float *)frect;
IMB_rectcpy(ibuf, tmpibuf, 0, 0, 0, 0, oldw, oldh);
IMB_scaleImBuf(ibuf, neww, newh);
IMB_rectcpy(ibuf, tmpibuf, 0, 0, 0, 0, w, h);
}
else if (rect) {
ibuf = IMB_allocImBuf(oldw, oldh, 32, IB_rect);
ibuf = IMB_allocImBuf(w, h, 32, IB_rect);
tmpibuf->rect = (unsigned int *)rect;
IMB_rectcpy(ibuf, tmpibuf, 0, 0, 0, 0, oldw, oldh);
IMB_scaleImBuf(ibuf, neww, newh);
IMB_rectcpy(ibuf, tmpibuf, 0, 0, 0, 0, w, h);
}
/* important, else we clean the source image imbufs! */