diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 38606a86c..7a8dc715c 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -143,14 +143,7 @@ void Crop::update (int todo) { if (todo & (M_INIT|M_LINDENOISE)) { MyMutex::MyLock lock(parent->minit); // Also used in improccoord - int tr = TR_NONE; - if (params.coarse.rotate==90) tr |= TR_R90; - else if (params.coarse.rotate==180) tr |= TR_R180; - else if (params.coarse.rotate==270) tr |= TR_R270; - - if (params.coarse.hflip) tr |= TR_HFLIP; - if (params.coarse.vflip) tr |= TR_VFLIP; - + int tr = getCoarseBitMask(params.coarse); if (!needsinitupdate) setCropSizes (rqcropx, rqcropy, rqcropw, rqcroph, skip, true); @@ -907,13 +900,8 @@ if (settings->verbose) printf ("setcropsizes before lock\n"); int orx, ory, orw, orh; ProcParams& params = parent->params; parent->ipf.transCoord (parent->fw, parent->fh, bx1, by1, bw, bh, orx, ory, orw, orh); - - int tr = TR_NONE; - if (params.coarse.rotate==90) tr |= TR_R90; - if (params.coarse.rotate==180) tr |= TR_R180; - if (params.coarse.rotate==270) tr |= TR_R270; - if (params.coarse.hflip) tr |= TR_HFLIP; - if (params.coarse.vflip) tr |= TR_VFLIP; + + int tr = getCoarseBitMask(params.coarse); PreviewProps cp (orx, ory, orw, orh, skip); int orW, orH; diff --git a/rtengine/iimage.cc b/rtengine/iimage.cc index b0169be0b..9296fd837 100644 --- a/rtengine/iimage.cc +++ b/rtengine/iimage.cc @@ -1,24 +1,43 @@ -/* - * This file is part of RawTherapee. - * - * Copyright (c) 2004-2010 Gabor Horvath - * - * RawTherapee is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * RawTherapee is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with RawTherapee. If not, see . - */ - -#include "rtengine.h" - -const char rtengine::sImage8[] = "Image8"; -const char rtengine::sImage16[] = "Image16"; -const char rtengine::sImagefloat[] = "Imagefloat"; +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2004-2010 Gabor Horvath + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ + +#include "rtengine.h" + +const char rtengine::sImage8[] = "Image8"; +const char rtengine::sImage16[] = "Image16"; +const char rtengine::sImagefloat[] = "Imagefloat"; +int rtengine::getCoarseBitMask( const procparams::CoarseTransformParams &coarse) +{ + int tr = TR_NONE; + if (coarse.rotate == 90) { + tr |= TR_R90; + } else if (coarse.rotate == 180) { + tr |= TR_R180; + } else if (coarse.rotate == 270) { + tr |= TR_R270; + } + + if (coarse.hflip) { + tr |= TR_HFLIP; + } + if (coarse.vflip) { + tr |= TR_VFLIP; + } + return tr; +} diff --git a/rtengine/iimage.h b/rtengine/iimage.h index 861929845..812b260dd 100644 --- a/rtengine/iimage.h +++ b/rtengine/iimage.h @@ -48,7 +48,7 @@ namespace rtengine { extern const char sImage8[]; extern const char sImage16[]; extern const char sImagefloat[]; - + int getCoarseBitMask( const procparams::CoarseTransformParams &coarse); class ProgressListener; class Color; diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 0af3ae0b2..a0533be47 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -255,13 +255,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { params.wb.temperature = currWB.getTemp (); params.wb.green = currWB.getGreen (); - int tr = TR_NONE; - if (params.coarse.rotate==90) tr |= TR_R90; - else if (params.coarse.rotate==180) tr |= TR_R180; - else if (params.coarse.rotate==270) tr |= TR_R270; - - if (params.coarse.hflip) tr |= TR_HFLIP; - if (params.coarse.vflip) tr |= TR_VFLIP; + int tr = getCoarseBitMask(params.coarse); imgsrc->getFullSize (fw, fh, tr); PreviewProps pp (0, 0, fw, fh, scale); @@ -754,12 +748,7 @@ void ImProcCoordinator::setScale (int prevscale) { if (settings->verbose) printf ("setscale before lock\n"); - tr = TR_NONE; - if (params.coarse.rotate==90) tr |= TR_R90; - if (params.coarse.rotate==180) tr |= TR_R180; - if (params.coarse.rotate==270) tr |= TR_R270; - if (params.coarse.hflip) tr |= TR_HFLIP; - if (params.coarse.vflip) tr |= TR_VFLIP; + tr = getCoarseBitMask(params.coarse); int nW, nH; imgsrc->getFullSize (fw, fh, tr); @@ -905,12 +894,9 @@ void ImProcCoordinator::getSpotWB (int x, int y, int rect, double& temp, double& points.push_back (Coord2D (j, i)); ipf.transCoord (fw, fh, points, red, green, blue); - int tr = TR_NONE; - if (params.coarse.rotate==90) tr |= TR_R90; - if (params.coarse.rotate==180) tr |= TR_R180; - if (params.coarse.rotate==270) tr |= TR_R270; - if (params.coarse.hflip) tr |= TR_HFLIP; - if (params.coarse.vflip) tr |= TR_VFLIP; + + int tr = getCoarseBitMask(params.coarse); + ret = imgsrc->getSpotWB (red, green, blue, tr, params.wb.equal); currWB = ColorTemp (params.wb.temperature, params.wb.green,params.wb.equal, params.wb.method); //double rr,gg,bb; @@ -961,7 +947,10 @@ void ImProcCoordinator::saveInputICCReference (const Glib::ustring& fname, bool MyMutex::MyLock lock(mProcessing); int fW, fH; - imgsrc->getFullSize (fW, fH, 0); + + int tr = getCoarseBitMask(params.coarse); + + imgsrc->getFullSize (fW, fH, tr); PreviewProps pp (0, 0, fW, fH, 1); ProcParams ppar = params; ppar.toneCurve.hrenabled = false; @@ -990,7 +979,7 @@ void ImProcCoordinator::saveInputICCReference (const Glib::ustring& fname, bool if (!apply_wb) { currWB = ColorTemp(); // = no white balance } - imgsrc->getImage (currWB, 0, im, pp, ppar.toneCurve, ppar.icm, ppar.raw); + imgsrc->getImage (currWB, tr, im, pp, ppar.toneCurve, ppar.icm, ppar.raw); ImProcFunctions ipf (&ppar, true); if (ipf.needsTransform()) { Imagefloat* trImg = new Imagefloat (fW, fH); @@ -1029,6 +1018,9 @@ void ImProcCoordinator::saveInputICCReference (const Glib::ustring& fname, bool } im16->saveTIFF (fname,16,true); delete im16; + + if (plistener) + plistener->setProgressState (false); //im->saveJPEG (fname, 85); } diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 66fa5d159..f05ab3237 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -254,7 +254,7 @@ class ImProcFunctions { void lab2monitorRgb (LabImage* lab, Image8* image); void resize (Image16* src, Image16* dst, float dScale); void Lanczos (const LabImage* src, LabImage* dst, float scale); -// void Lanczos (const Image16* src, Image16* dst, float scale); + void Lanczos (const Image16* src, Image16* dst, float scale); void deconvsharpening (LabImage* lab, float** buffer); void deconvsharpeningcam (CieImage* ncie, float** buffer); diff --git a/rtengine/ipresize.cc b/rtengine/ipresize.cc index ff82a4377..29e25107d 100644 --- a/rtengine/ipresize.cc +++ b/rtengine/ipresize.cc @@ -41,7 +41,6 @@ static inline float Lanc(float x, float a) } } -/* This Function is not used anymore void ImProcFunctions::Lanczos(const Image16* src, Image16* dst, float scale) { @@ -167,7 +166,7 @@ void ImProcFunctions::Lanczos(const Image16* src, Image16* dst, float scale) delete[] lb; } } -*/ + SSEFUNCTION void ImProcFunctions::Lanczos(const LabImage* src, LabImage* dst, float scale) { @@ -381,119 +380,13 @@ void ImProcFunctions::resize (Image16* src, Image16* dst, float dScale) { #ifdef PROFILE time_t t1 = clock(); #endif + if(params->resize.method != "Nearest" ) { + Lanczos(src, dst, dScale); + } else { // Nearest neighbour algorithm #ifdef _OPENMP #pragma omp parallel for if (multiThread) #endif - for (int i=0; iheight; i++) { - int sy = i/dScale; - sy = LIM(sy, 0, src->height-1); - for (int j=0; jwidth; j++) { - int sx = j/dScale; - sx = LIM(sx, 0, src->width-1); - dst->r(i,j) = src->r(sy,sx); - dst->g(i,j) = src->g(sy,sx); - dst->b(i,j) = src->b(sy,sx); - } - } -/* not used anymore - if(params->resize.method == "Lanczos" || - params->resize.method == "Downscale (Better)" || - params->resize.method == "Downscale (Faster)" - ) { - Lanczos(src, dst, dScale); - } else { - } - - else if (params->resize.method.substr(0,7)=="Bicubic") { - float Av = -0.5f; - if (params->resize.method=="Bicubic (Sharper)") - Av = -0.75f; - else if (params->resize.method=="Bicubic (Softer)") - Av = -0.25f; - #pragma omp parallel for if (multiThread) - for (int i=0; iheight; i++) { - float wx[4], wy[4]; - float Dy = i / dScale; - int yc = (int) Dy; - Dy -= (float)yc; - int ys = yc - 1; // smallest y-index used for interpolation - // compute vertical weights - float t1y = -Av*(Dy-1.0f)*Dy; - float t2y = (3.0f - 2.0f*Dy)*Dy*Dy; - wy[3] = t1y*Dy; - wy[2] = t1y*(Dy - 1.0f) + t2y; - wy[1] = -t1y*Dy + 1.0f - t2y; - wy[0] = -t1y*(Dy - 1.0f); - for (int j = 0; j < dst->width; j++) { - float Dx = j / dScale; - int xc = (int) Dx; - Dx -= (float)xc; - int xs = xc - 1; // smallest x-index used for interpolation - if (ys >= 0 && ys < src->height-3 && xs >= 0 && xs <= src->width-3) { - // compute horizontal weights - float t1 = -Av*(Dx-1.0f)*Dx; - float t2 = (3.0f - 2.0f*Dx)*Dx*Dx; - wx[3] = t1*Dx; - wx[2] = t1*(Dx - 1.0f) + t2; - wx[1] = -t1*Dx + 1.0f - t2; - wx[0] = -t1*(Dx - 1.0f); - // compute weighted sum - int r = 0; - int g = 0; - int b = 0; - for (int x=0; x<4; x++) - for (int y=0; y<4; y++) { - float w = wx[x]*wy[y]; - r += w*src->r(ys+y,xs+x); - g += w*src->g(ys+y,xs+x); - b += w*src->b(ys+y,xs+x); - } - dst->r(i,j) = CLIP(r); - dst->g(i,j) = CLIP(g); - dst->b(i,j) = CLIP(b); - } - else { - xc = LIM(xc, 0, src->width-1); - yc = LIM(yc, 0, src->height-1); - int nx = xc + 1; - if (nx >= src->width) - nx = xc; - int ny = yc + 1; - if (ny >= src->height) - ny = yc; - dst->r(i,j) = (1-Dx)*(1-Dy)*src->r(yc,xc) + (1-Dx)*Dy*src->r(ny,xc) + Dx*(1-Dy)*src->r(yc,nx) + Dx*Dy*src->r(ny,nx); - dst->g(i,j) = (1-Dx)*(1-Dy)*src->g(yc,xc) + (1-Dx)*Dy*src->g(ny,xc) + Dx*(1-Dy)*src->g(yc,nx) + Dx*Dy*src->g(ny,nx); - dst->b(i,j) = (1-Dx)*(1-Dy)*src->b(yc,xc) + (1-Dx)*Dy*src->b(ny,xc) + Dx*(1-Dy)*src->b(yc,nx) + Dx*Dy*src->b(ny,nx); - } - } - } - } - else if (params->resize.method=="Bilinear") { - #pragma omp parallel for if (multiThread) - for (int i=0; iheight; i++) { - int sy = i/dScale; - sy = LIM(sy, 0, src->height-1); - float dy = i/dScale - sy; - int ny = sy+1; - if (ny>=src->height) - ny = sy; - for (int j=0; jwidth; j++) { - int sx = j/dScale; - sx = LIM(sx, 0, src->width-1); - float dx = j/dScale - sx; - int nx = sx+1; - if (nx>=src->width) - nx = sx; - dst->r(i,j) = (1-dx)*(1-dy)*src->r(sy,sx) + (1-dx)*dy*src->r(ny,sx) + dx*(1-dy)*src->r(sy,nx) + dx*dy*src->r(ny,nx); - dst->g(i,j) = (1-dx)*(1-dy)*src->g(sy,sx) + (1-dx)*dy*src->g(ny,sx) + dx*(1-dy)*src->g(sy,nx) + dx*dy*src->g(ny,nx); - dst->b(i,j) = (1-dx)*(1-dy)*src->b(sy,sx) + (1-dx)*dy*src->b(ny,sx) + dx*(1-dy)*src->b(sy,nx) + dx*dy*src->b(ny,nx); - } - } - } - else { - // Nearest neighbour algorithm - #pragma omp parallel for if (multiThread) for (int i=0; iheight; i++) { int sy = i/dScale; sy = LIM(sy, 0, src->height-1); @@ -506,7 +399,7 @@ void ImProcFunctions::resize (Image16* src, Image16* dst, float dScale) { } } } -*/ + #ifdef PROFILE time_t t2 = clock(); std::cout << "Resize: " << params->resize.method << ": " diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index 7edd2c670..8030df11e 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -1181,13 +1181,7 @@ void Thumbnail::getSpotWB (const procparams::ProcParams& params, int xp, int yp, } ImProcFunctions ipf (¶ms, false); ipf.transCoord (fw, fh, points, red, green, blue); - int tr = TR_NONE; - if (params.coarse.rotate==90) tr |= TR_R90; - if (params.coarse.rotate==180) tr |= TR_R180; - if (params.coarse.rotate==270) tr |= TR_R270; - if (params.coarse.hflip) tr |= TR_HFLIP; - if (params.coarse.vflip) tr |= TR_VFLIP; - + int tr = getCoarseBitMask(params.coarse); // calculate spot wb (copy & pasted from stdimagesource) double reds = 0, greens = 0, blues = 0; int rn = 0, gn = 0, bn = 0; diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 186d470bf..1e093fd34 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -63,13 +63,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p // acquire image from imagesource ImageSource* imgsrc = ii->getImageSource (); - int tr = TR_NONE; - if (params.coarse.rotate==90) tr |= TR_R90; - if (params.coarse.rotate==180) tr |= TR_R180; - if (params.coarse.rotate==270) tr |= TR_R270; - if (params.coarse.hflip) tr |= TR_HFLIP; - if (params.coarse.vflip) tr |= TR_VFLIP; - + int tr = getCoarseBitMask(params.coarse); int fw, fh; imgsrc->getFullSize (fw, fh, tr);