make smoother zoomed preview OpenMP enabled and fix for edges which can cause crashes.

This commit is contained in:
janrinze
2010-12-12 19:14:58 +01:00
parent 98a4daf9af
commit 2a1f3c17d0
2 changed files with 48 additions and 15 deletions

View File

@@ -235,36 +235,52 @@ void RawImageSource::getImage (ColorTemp ctemp, int tran, Image16* image, Previe
imwidth = maximwidth;
if (!fuji && imheight>maximheight)
imheight = maximheight;
#ifdef _OPENMP
#pragma omp parallel
{
#endif
// render the requested image part
unsigned short* red = new unsigned short[imwidth];
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; ix<imheight; i+=pp.skip, ix++) {
int maxx=this->W,maxy=this->H;
#ifdef _OPENMP
#pragma omp for
#endif
for (int ix=0; ix<imheight; ix++) { int i=sy1+pp.skip*ix;
if (ri->isBayer()) {
for (int j=0,jx=sx1; j<imwidth; j++,jx+=pp.skip) {
rtot=gtot=btot=0;
float rtot,gtot,btot;
rtot=gtot=btot=0;
int boxarea=0;
for (int m=0; m<pp.skip; m++)
for (int n=0; n<pp.skip; n++) {
for (int n=0; n<pp.skip; n++)
if ((i+m<maxy)&&(jx+n<maxx))
{
rtot += this->red[i+m][jx+n];
gtot += this->green[i+m][jx+n];
btot += this->blue[i+m][jx+n];
boxarea++;
}
if (boxarea<1) boxarea=1;
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; j<imwidth; j++,jx+=pp.skip) {
rtot=gtot=btot=0;
float rtot,gtot,btot;
rtot=gtot=btot=0;
int boxarea=0;
for (int m=0; m<pp.skip; m++)
for (int n=0; n<pp.skip; n++) {
for (int n=0; n<pp.skip; n++)
if ((i+m<maxy)&&(jx+n<maxx)) {
rtot += rawData[i+m][(jx+n)*3+0];
gtot += rawData[i+m][(jx+n)*3+1];
btot += rawData[i+m][(jx+n)*3+2];
boxarea++;
}
red[j] = CLIP(rm*rtot/boxarea);
grn[j] = CLIP(gm*gtot/boxarea);
@@ -282,7 +298,9 @@ void RawImageSource::getImage (ColorTemp ctemp, int tran, Image16* image, Previe
delete [] red;
delete [] grn;
delete [] blue;
#ifdef _OPENMP
}
#endif
if (fuji) {
int a = ((tran & TR_ROT) == TR_R90 && image->width%2==0) || ((tran & TR_ROT) == TR_R180 && image->height%2+image->width%2==1) || ((tran & TR_ROT) == TR_R270 && image->height%2==0);
// first row

View File

@@ -178,22 +178,33 @@ void StdImageSource::getImage_ (ColorTemp ctemp, int tran, Image16* image, Previ
int mtran = tran;
int skip = pp.skip;
#ifdef _OPENMP
#pragma omp parallel
{
#endif
unsigned short* red = new unsigned short[imwidth];
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=istart; i<iend; i+=skip, ix++) {
int maxx=img->width,maxy=img->height;
int b_ix=ix;
#ifdef _OPENMP
#pragma omp for
#endif
for (int i=istart; i<iend; i+=skip) { ix=b_ix+i/skip;
for (int j=0,jx=sx1; j<imwidth; j++,jx+=pp.skip) {
float rtot,gtot,btot;
rtot=gtot=btot=0;
int boxarea=0;
for (int m=0; m<pp.skip; m++)
for (int n=0; n<pp.skip; n++) {
for (int n=0; n<pp.skip; n++)
if ((i+m<maxy)&&(jx+n<maxx)){
rtot += img->r[i+m][jx+n];
gtot += img->g[i+m][jx+n];
btot += img->b[i+m][jx+n];
}
boxarea++;
}
if (boxarea<1) boxarea=1;
red[j] = round(rtot/boxarea);
grn[j] = round(gtot/boxarea);
blue[j] = round(btot/boxarea);
@@ -231,8 +242,12 @@ void StdImageSource::getImage_ (ColorTemp ctemp, int tran, Image16* image, Previ
delete [] red;
delete [] grn;
delete [] blue;
#ifdef _OPENMP
}
#endif
}
void StdImageSource::getImage (ColorTemp ctemp, int tran, Image16* image, PreviewProps pp, HRecParams hrp, ColorManagementParams cmp, RAWParams raw) {
MyTime t1,t2;