Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-03-08 18:23:34 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-03-08 18:23:34 +0400
commit3675fab31d9e763069b01ba24fae1864583d8313 (patch)
treea4694e5ae0140ae4bbbe1f9f26dc36a8425ef50e /source/blender/imbuf/intern/imageprocess.c
parenta80b7d612947e1d26b10165a37bb603dae527afd (diff)
Fix #30485: TRANSFORM / STABILIZE 2D: First row / column blackness.
Clamp source coordinates to boundaries so it'll be kind of correct weight calculated for the pixel.
Diffstat (limited to 'source/blender/imbuf/intern/imageprocess.c')
-rw-r--r--source/blender/imbuf/intern/imageprocess.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c
index 9dad21aa728..cd3fc654d8e 100644
--- a/source/blender/imbuf/intern/imageprocess.c
+++ b/source/blender/imbuf/intern/imageprocess.c
@@ -42,6 +42,8 @@
#include <stdlib.h>
+#include "BLI_utildefines.h"
+
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
#include "math.h"
@@ -134,6 +136,10 @@ void bicubic_interpolation_color(struct ImBuf *in, unsigned char *outI, float *o
unsigned char *dataI;
float a,b,w,wx,wy[4], outR,outG,outB,outA,*dataF;
+ /* sample area entirely outside image? */
+ if (ceil(u)<0 || floor(u)>in->x-1 || ceil(v)<0 || floor(v)>in->y-1)
+ return;
+
/* ImBuf in must have a valid rect or rect_float, assume this is already checked */
i= (int)floor(u);
@@ -153,31 +159,29 @@ void bicubic_interpolation_color(struct ImBuf *in, unsigned char *outI, float *o
for(n= -1; n<= 2; n++){
x1= i+n;
- if (x1>0 && x1 < in->x) {
- wx = P(n-a);
- for(m= -1; m<= 2; m++){
- y1= j+m;
- if (y1>0 && y1<in->y) {
- /* normally we could do this */
- /* w = P(n-a) * P(b-m); */
- /* except that would call P() 16 times per pixel therefor pow() 64 times, better precalc these */
- w = wx * wy[m+1];
-
- if (outF) {
- dataF= in->rect_float + in->x * y1 * 4 + 4*x1;
- outR+= dataF[0] * w;
- outG+= dataF[1] * w;
- outB+= dataF[2] * w;
- outA+= dataF[3] * w;
- }
- if (outI) {
- dataI= (unsigned char*)in->rect + in->x * y1 * 4 + 4*x1;
- outR+= dataI[0] * w;
- outG+= dataI[1] * w;
- outB+= dataI[2] * w;
- outA+= dataI[3] * w;
- }
- }
+ CLAMP(x1, 0, in->x-1);
+ wx = P(n-a);
+ for(m= -1; m<= 2; m++){
+ y1= j+m;
+ CLAMP(y1, 0, in->y-1);
+ /* normally we could do this */
+ /* w = P(n-a) * P(b-m); */
+ /* except that would call P() 16 times per pixel therefor pow() 64 times, better precalc these */
+ w = wx * wy[m+1];
+
+ if (outF) {
+ dataF= in->rect_float + in->x * y1 * 4 + 4*x1;
+ outR+= dataF[0] * w;
+ outG+= dataF[1] * w;
+ outB+= dataF[2] * w;
+ outA+= dataF[3] * w;
+ }
+ if (outI) {
+ dataI= (unsigned char*)in->rect + in->x * y1 * 4 + 4*x1;
+ outR+= dataI[0] * w;
+ outG+= dataI[1] * w;
+ outB+= dataI[2] * w;
+ outA+= dataI[3] * w;
}
}
}