diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index dc31e81ea..c587962de 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -241,19 +241,35 @@ void RawImageSource::getImage (ColorTemp ctemp, int tran, Image16* image, Previe unsigned short* grn = new unsigned short[imwidth]; unsigned short* blue = new unsigned short[imwidth]; + float rtot,gtot,btot; + int boxarea=SQR(pp.skip); for (int i=sy1,ix=0; ixisBayer()) { for (int j=0,jx=sx1; jred[i][jx]); - grn[j] = CLIP(gm*this->green[i][jx]); - blue[j] = CLIP(bm*this->blue[i][jx]); + rtot=gtot=btot=0; + for (int m=0; mred[i+m][jx+n]; + gtot += this->green[i+m][jx+n]; + btot += this->blue[i+m][jx+n]; + } + red[j] = CLIP(rm*rtot/boxarea); + grn[j] = CLIP(gm*gtot/boxarea); + blue[j] = CLIP(bm*btot/boxarea); } } else { for (int j=0,jx=sx1; jr[i][jx]; - grn[j] = img->g[i][jx]; - blue[j] = img->b[i][jx]; - } + for (int j=0,jx=sx1; jr[i+m][jx+n]; + gtot += img->g[i+m][jx+n]; + btot += img->b[i+m][jx+n]; + } + + red[j] = round(rtot/boxarea); + grn[j] = round(gtot/boxarea); + blue[j] = round(btot/boxarea); + } // if (hrp.enabled) // hlRecovery (red, grn, blue, i, sx1, sx2, pp.skip);