diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 23b724b2b..5aea884fb 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -340,7 +340,7 @@ void ImProcFunctions::updateColorProfiles (const Glib::ustring& monitorProfile, monitorTransform = cmsCreateProofingTransform ( iprof, TYPE_Lab_FLT, - monitor, TYPE_RGB_8, + monitor, TYPE_RGB_FLT, oprof, monitorIntent, outIntent, flags @@ -383,7 +383,7 @@ void ImProcFunctions::updateColorProfiles (const Glib::ustring& monitorProfile, flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; } - monitorTransform = cmsCreateTransform (iprof, TYPE_Lab_FLT, monitor, TYPE_RGB_8, monitorIntent, flags); + monitorTransform = cmsCreateTransform (iprof, TYPE_Lab_FLT, monitor, TYPE_RGB_FLT, monitorIntent, flags); } if (gamutCheck && gamutprof) { diff --git a/rtengine/iplab2rgb.cc b/rtengine/iplab2rgb.cc index 77cf65d21..314020cb9 100644 --- a/rtengine/iplab2rgb.cc +++ b/rtengine/iplab2rgb.cc @@ -32,65 +32,61 @@ namespace rtengine extern void filmlike_clip(float *r, float *g, float *b); -namespace +extern const Settings* settings; + +namespace { + +inline void copyAndClampLine(const float *src, unsigned char *dst, const int W) { - -inline void clipLAB(float iL, float ia, float ib, float &oL, float &oa, float &ob, const float scale, const float wp[3][3], const float wip[3][3]) -{ - if (iL < 0.f) { - oL = oa = ob = 0.f; - } else if (iL > 32768.f || min(ia, ib) < -42000.f || max(ia, ib) > 42000.f) { - - float X, Y, Z; - float r, g, b; - Color::Lab2XYZ(iL, ia, ib, X, Y, Z); - Color::xyz2rgb(X, Y, Z, r, g, b, wip); - filmlike_clip(&r, &g, &b); - Color::rgbxyz(r, g, b, X, Y, Z, wp); - Color::XYZ2Lab(X, Y, Z, oL, oa, ob); - oL /= scale; - oa /= scale; - ob /= scale; - - // oL = 32768.f / scale; - // oa = ob = 0.f; - } else { - oL = iL / scale; - oa = ia / scale; - ob = ib / scale; + for (int j = 0, iy = 0; j < W; ++j) { + float r = src[iy] * MAXVALF; + float g = src[iy+1] * MAXVALF; + float b = src[iy+2] * MAXVALF; + if (r > MAXVALF || g > MAXVALF || b > MAXVALF) { + filmlike_clip(&r, &g, &b); + } + dst[iy] = uint16ToUint8Rounded(CLIP(r)); + dst[iy+1] = uint16ToUint8Rounded(CLIP(g)); + dst[iy+2] = uint16ToUint8Rounded(CLIP(b)); + iy += 3; } } -inline void clipLAB(float iL, float ia, float ib, double &oL, double &oa, double &ob, const float scale, const float wp[3][3], const float wip[3][3]) +inline void copyAndClamp(const LabImage *src, unsigned char *dst, const double rgb_xyz[3][3], bool multiThread) { - float tL, ta, tb; - clipLAB(iL, ia, ib, tL, ta, tb, scale, wp, wip); - oL = tL; - oa = ta; - ob = tb; + int W = src->W; + int H = src->H; + +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) if (multiThread) +#endif + for (int i = 0; i < H; ++i) { + float* rL = src->L[i]; + float* ra = src->a[i]; + float* rb = src->b[i]; + int ix = i * 3 * W; + + float R, G, B; + float x_, y_, z_; + + for (int j = 0; j < W; ++j) { + Color::Lab2XYZ(rL[j], ra[j], rb[j], x_, y_, z_ ); + Color::xyz2rgb(x_, y_, z_, R, G, B, rgb_xyz); + + if (R > MAXVALF || G > MAXVALF || B > MAXVALF) { + filmlike_clip(&R, &G, &B); + } + + dst[ix++] = uint16ToUint8Rounded(Color::gamma2curve[R]); + dst[ix++] = uint16ToUint8Rounded(Color::gamma2curve[G]); + dst[ix++] = uint16ToUint8Rounded(Color::gamma2curve[B]); + } + } } } // namespace -extern const Settings* settings; - -#define DECLARE_WORKING_MATRICES_(space) \ - TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix ( space ); \ - const float wp[3][3] = { \ - {static_cast (wprof[0][0]), static_cast (wprof[0][1]), static_cast (wprof[0][2])}, \ - {static_cast (wprof[1][0]), static_cast (wprof[1][1]), static_cast (wprof[1][2])}, \ - {static_cast (wprof[2][0]), static_cast (wprof[2][1]), static_cast (wprof[2][2])} \ - }; \ - \ - TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix ( space ); \ - const float wip[3][3] = { \ - {static_cast (wiprof[0][0]), static_cast (wiprof[0][1]), static_cast (wiprof[0][2])}, \ - {static_cast (wiprof[1][0]), static_cast (wiprof[1][1]), static_cast (wiprof[1][2])}, \ - {static_cast (wiprof[2][0]), static_cast (wiprof[2][1]), static_cast (wiprof[2][2])} \ - } - - // Used in ImProcCoordinator::updatePreviewImage (rtengine/improccoordinator.cc) // Crop::update (rtengine/dcrop.cc) // Thumbnail::processImage (rtengine/rtthumbnail.cc) @@ -99,8 +95,6 @@ extern const Settings* settings; // otherwise divide by 327.68, convert to xyz and apply the sRGB transform, before converting with gamma2curve void ImProcFunctions::lab2monitorRgb(LabImage* lab, Image8* image) { - DECLARE_WORKING_MATRICES_(params->icm.working); - if (monitorTransform) { int W = lab->W; @@ -113,6 +107,7 @@ void ImProcFunctions::lab2monitorRgb(LabImage* lab, Image8* image) #endif { AlignedBuffer pBuf(3 * lab->W); + AlignedBuffer mBuf(3 * lab->W); AlignedBuffer gwBuf1; AlignedBuffer gwBuf2; @@ -123,6 +118,7 @@ void ImProcFunctions::lab2monitorRgb(LabImage* lab, Image8* image) } float *buffer = pBuf.data; + float *outbuffer = mBuf.data; #ifdef _OPENMP #pragma omp for schedule(dynamic,16) @@ -138,11 +134,13 @@ void ImProcFunctions::lab2monitorRgb(LabImage* lab, Image8* image) float* rb = lab->b[i]; for (int j = 0; j < W; j++) { - clipLAB(rL[j], ra[j], rb[j], buffer[iy], buffer[iy + 1], buffer[iy + 2], 327.68f, wp, wip); - iy += 3; + buffer[iy++] = rL[j] / 327.68f; + buffer[iy++] = ra[j] / 327.68f; + buffer[iy++] = rb[j] / 327.68f; } - cmsDoTransform(monitorTransform, buffer, data + ix, W); + cmsDoTransform (monitorTransform, buffer, outbuffer, W); + copyAndClampLine(outbuffer, data + ix, W); if (gamutWarning) { gamutWarning->markLine(image, i, buffer, gwBuf1.data, gwBuf2.data); @@ -150,41 +148,7 @@ void ImProcFunctions::lab2monitorRgb(LabImage* lab, Image8* image) } } // End of parallelization } else { - - int W = lab->W; - int H = lab->H; - unsigned char * data = image->data; - -#ifdef _OPENMP - #pragma omp parallel for schedule(dynamic,16) if (multiThread) -#endif - - for (int i = 0; i < H; ++i) { - float* rL = lab->L[i]; - float* ra = lab->a[i]; - float* rb = lab->b[i]; - int ix = i * 3 * W; - - float R, G, B; - float x_, y_, z_; - float L, a, b; - - for (int j = 0; j < W; ++j) { - - //float L1=rL[j],a1=ra[j],b1=rb[j];//for testing - clipLAB(rL[j], ra[j], rb[j], L, a, b, 1.f, wp, wip); - - Color::Lab2XYZ(L, a, b, x_, y_, z_); - - Color::xyz2srgb(x_, y_, z_, R, G, B); - - /* copy RGB */ - //int R1=((int)gamma2curve[(R)]) - data[ix++] = uint16ToUint8Rounded(Color::gamma2curve[R]); - data[ix++] = uint16ToUint8Rounded(Color::gamma2curve[G]); - data[ix++] = uint16ToUint8Rounded(Color::gamma2curve[B]); - } - } + copyAndClamp(lab, image->data, sRGB_xyz, multiThread); } } @@ -199,8 +163,6 @@ void ImProcFunctions::lab2monitorRgb(LabImage* lab, Image8* image) // otherwise divide by 327.68, convert to xyz and apply the RGB transform, before converting with gamma2curve Image8* ImProcFunctions::lab2rgb(LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, bool consider_histogram_settings) { - DECLARE_WORKING_MATRICES_(icm.working); - //gamutmap(lab); if (cx < 0) { @@ -254,7 +216,7 @@ Image8* ImProcFunctions::lab2rgb(LabImage* lab, int cx, int cy, int cw, int ch, lcmsMutex->lock(); cmsHPROFILE LabIProf = cmsCreateLab4Profile(nullptr); - cmsHTRANSFORM hTransform = cmsCreateTransform(LabIProf, TYPE_Lab_DBL, oprofG, TYPE_RGB_8, icm.outputIntent, flags); // NOCACHE is important for thread safety + cmsHTRANSFORM hTransform = cmsCreateTransform (LabIProf, TYPE_Lab_DBL, oprofG, TYPE_RGB_FLT, icm.outputIntent, flags); // NOCACHE is important for thread safety cmsCloseProfile(LabIProf); lcmsMutex->unlock(); @@ -266,7 +228,9 @@ Image8* ImProcFunctions::lab2rgb(LabImage* lab, int cx, int cy, int cw, int ch, #endif { AlignedBuffer pBuf(3 * cw); + AlignedBuffer oBuf(3 * cw); double *buffer = pBuf.data; + float *outbuffer = oBuf.data; int condition = cy + ch; #ifdef _OPENMP @@ -281,11 +245,13 @@ Image8* ImProcFunctions::lab2rgb(LabImage* lab, int cx, int cy, int cw, int ch, float* rb = lab->b[i]; for (int j = cx; j < cx + cw; j++) { - clipLAB(rL[j], ra[j], rb[j], buffer[iy], buffer[iy + 1], buffer[iy + 2], 327.68f, wp, wip); - iy += 3; + buffer[iy++] = rL[j] / 327.68f; + buffer[iy++] = ra[j] / 327.68f; + buffer[iy++] = rb[j] / 327.68f; } - cmsDoTransform(hTransform, buffer, data + ix, cw); + cmsDoTransform (hTransform, buffer, outbuffer, cw); + copyAndClampLine(outbuffer, data + ix, cw); } } // End of parallelization @@ -295,34 +261,8 @@ Image8* ImProcFunctions::lab2rgb(LabImage* lab, int cx, int cy, int cw, int ch, cmsCloseProfile(oprofG); } } else { - const auto xyz_rgb = ICCStore::getInstance()->workingSpaceInverseMatrix(profile); - -#ifdef _OPENMP - #pragma omp parallel for schedule(dynamic,16) if (multiThread) -#endif - - for (int i = cy; i < cy + ch; ++i) { - float* rL = lab->L[i]; - float* ra = lab->a[i]; - float* rb = lab->b[i]; - int ix = 3 * i * cw; - - float R, G, B; - float x_, y_, z_; - float L, a, b; - - for (int j = cx; j < cx + cw; ++j) { - clipLAB(rL[j], ra[j], rb[j], L, a, b, 1.f, wp, wip); - Color::Lab2XYZ(rL[j], ra[j], rb[j], x_, y_, z_); - - Color::xyz2rgb(x_, y_, z_, R, G, B, xyz_rgb); - - image->data[ix++] = uint16ToUint8Rounded(Color::gamma2curve[R]); - image->data[ix++] = uint16ToUint8Rounded(Color::gamma2curve[G]); - image->data[ix++] = uint16ToUint8Rounded(Color::gamma2curve[B]); - } - } + copyAndClamp(lab, image->data, xyz_rgb, multiThread); } return image; @@ -392,6 +332,7 @@ Imagefloat* ImProcFunctions::lab2rgbOut(LabImage* lab, int cx, int cy, int cw, i cmsDeleteTransform(hTransform); image->normalizeFloatTo65535(); } else { + #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) if (multiThread) #endif diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index f786b482c..a6811df08 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -154,7 +154,7 @@ void transLineFuji (const float* const red, const float* const green, const floa } } -void transLineD1x (const float* const red, const float* const green, const float* const blue, const int i, rtengine::Imagefloat* const image, const int tran, const int imwidth, const int imheight, const bool oddHeight) +void transLineD1x (const float* const red, const float* const green, const float* const blue, const int i, rtengine::Imagefloat* const image, const int tran, const int imwidth, const int imheight, const bool oddHeight, const bool clip) { // Nikon D1X has an uncommon sensor with 4028 x 1324 sensels. // Vertical sensel size is 2x horizontal sensel size @@ -223,6 +223,12 @@ void transLineD1x (const float* const red, const float* const green, const float image->r(row, col) = MAX(0.f, -0.0625f * (red[j] + image->r(row + 3, col)) + 0.5625f * (image->r(row - 1, col) + image->r(row + 1, col))); image->g(row, col) = MAX(0.f, -0.0625f * (green[j] + image->g(row + 3, col)) + 0.5625f * (image->g(row - 1, col) + image->g(row + 1, col))); image->b(row, col) = MAX(0.f, -0.0625f * (blue[j] + image->b(row + 3, col)) + 0.5625f * (image->b(row - 1, col) + image->b(row + 1, col))); + + if(clip) { + image->r(row, col) = MIN(image->r(row, col), rtengine::MAXVALF); + image->g(row, col) = MIN(image->g(row, col), rtengine::MAXVALF); + image->b(row, col) = MIN(image->b(row, col), rtengine::MAXVALF); + } } } @@ -280,6 +286,12 @@ void transLineD1x (const float* const red, const float* const green, const float image->r(j, col) = MAX(0.f, -0.0625f * (red[j] + image->r(j, col + 3)) + 0.5625f * (image->r(j, col - 1) + image->r(j, col + 1))); image->g(j, col) = MAX(0.f, -0.0625f * (green[j] + image->g(j, col + 3)) + 0.5625f * (image->g(j, col - 1) + image->g(j, col + 1))); image->b(j, col) = MAX(0.f, -0.0625f * (blue[j] + image->b(j, col + 3)) + 0.5625f * (image->b(j, col - 1) + image->b(j, col + 1))); + + if(clip) { + image->r(j, col) = MIN(image->r(j, col), rtengine::MAXVALF); + image->g(j, col) = MIN(image->g(j, col), rtengine::MAXVALF); + image->b(j, col) = MIN(image->b(j, col), rtengine::MAXVALF); + } } } @@ -307,6 +319,12 @@ void transLineD1x (const float* const red, const float* const green, const float image->g(row, 2 * i - 3) = MAX(0.f, -0.0625f * (green[j] + image->g(row, 2 * i - 6)) + 0.5625f * (image->g(row, 2 * i - 2) + image->g(row, 2 * i - 4))); image->b(row, 2 * i - 3) = MAX(0.f, -0.0625f * (blue[j] + image->b(row, 2 * i - 6)) + 0.5625f * (image->b(row, 2 * i - 2) + image->b(row, 2 * i - 4))); + if(clip) { + image->r(row, 2 * i - 3) = MIN(image->r(row, 2 * i - 3), rtengine::MAXVALF); + image->g(row, 2 * i - 3) = MIN(image->g(row, 2 * i - 3), rtengine::MAXVALF); + image->b(row, 2 * i - 3) = MIN(image->b(row, 2 * i - 3), rtengine::MAXVALF); + } + image->r(row, 2 * i) = red[j]; image->g(row, 2 * i) = green[j]; image->b(row, 2 * i) = blue[j]; @@ -319,6 +337,12 @@ void transLineD1x (const float* const red, const float* const green, const float image->g(row, 2 * i - 1) = MAX(0.f, -0.0625f * (green[j] + image->g(row, 2 * i - 4)) + 0.5625f * (image->g(row, 2 * i) + image->g(row, 2 * i - 2))); image->b(row, 2 * i - 1) = MAX(0.f, -0.0625f * (blue[j] + image->b(row, 2 * i - 4)) + 0.5625f * (image->b(row, 2 * i) + image->b(row, 2 * i - 2))); + if(clip) { + image->r(j, 2 * i - 1) = MIN(image->r(j, 2 * i - 1), rtengine::MAXVALF); + image->g(j, 2 * i - 1) = MIN(image->g(j, 2 * i - 1), rtengine::MAXVALF); + image->b(j, 2 * i - 1) = MIN(image->b(j, 2 * i - 1), rtengine::MAXVALF); + } + image->r(row, 2 * i + 1) = (red[j] + image->r(row, 2 * i - 1)) / 2; image->g(row, 2 * i + 1) = (green[j] + image->g(row, 2 * i - 1)) / 2; image->b(row, 2 * i + 1) = (blue[j] + image->b(row, 2 * i - 1)) / 2; @@ -350,6 +374,12 @@ void transLineD1x (const float* const red, const float* const green, const float image->r(2 * i - 3, j) = MAX(0.f, -0.0625f * (red[j] + image->r(2 * i - 6, j)) + 0.5625f * (image->r(2 * i - 2, j) + image->r(2 * i - 4, j))); image->g(2 * i - 3, j) = MAX(0.f, -0.0625f * (green[j] + image->g(2 * i - 6, j)) + 0.5625f * (image->g(2 * i - 2, j) + image->g(2 * i - 4, j))); image->b(2 * i - 3, j) = MAX(0.f, -0.0625f * (blue[j] + image->b(2 * i - 6, j)) + 0.5625f * (image->b(2 * i - 2, j) + image->b(2 * i - 4, j))); + + if(clip) { + image->r(2 * i - 3, j) = MIN(image->r(2 * i - 3, j), rtengine::MAXVALF); + image->g(2 * i - 3, j) = MIN(image->g(2 * i - 3, j), rtengine::MAXVALF); + image->b(2 * i - 3, j) = MIN(image->b(2 * i - 3, j), rtengine::MAXVALF); + } } } @@ -359,6 +389,12 @@ void transLineD1x (const float* const red, const float* const green, const float image->g(2 * i - 1, j) = MAX(0.f, -0.0625f * (green[j] + image->g(2 * i - 4, j)) + 0.5625f * (image->g(2 * i, j) + image->g(2 * i - 2, j))); image->b(2 * i - 1, j) = MAX(0.f, -0.0625f * (blue[j] + image->b(2 * i - 4, j)) + 0.5625f * (image->b(2 * i, j) + image->b(2 * i - 2, j))); + if(clip) { + image->r(2 * i - 1, j) = MIN(image->r(2 * i - 1, j), rtengine::MAXVALF); + image->g(2 * i - 1, j) = MIN(image->g(2 * i - 1, j), rtengine::MAXVALF); + image->b(2 * i - 1, j) = MIN(image->b(2 * i - 1, j), rtengine::MAXVALF); + } + image->r(2 * i + 1, j) = (red[j] + image->r(2 * i - 1, j)) / 2; image->g(2 * i + 1, j) = (green[j] + image->g(2 * i - 1, j)) / 2; image->b(2 * i + 1, j) = (blue[j] + image->b(2 * i - 1, j)) / 2; @@ -688,6 +724,8 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima hlmax[1] = clmax[1] * gm; hlmax[2] = clmax[2] * bm; + const bool doClip = (chmax[0] >= clmax[0] || chmax[1] >= clmax[1] || chmax[2] >= clmax[2]) && !hrp.hrenabled && hrp.clampOOG; + float area = skip * skip; rm /= area; gm /= area; @@ -730,6 +768,17 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima gtot *= gm; btot *= bm; + if (doClip) { + // note: as hlmax[] can be larger than CLIP and we can later apply negative + // exposure this means that we can clip away local highlights which actually + // are not clipped. We have to do that though as we only check pixel by pixel + // and don't know if this will transition into a clipped area, if so we need + // to clip also surrounding to make a good colour transition + rtot = CLIP(rtot); + gtot = CLIP(gtot); + btot = CLIP(btot); + } + line_red[j] = rtot; line_grn[j] = gtot; line_blue[j] = btot; @@ -754,6 +803,12 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima gtot *= gm; btot *= bm; + if (doClip) { + rtot = CLIP(rtot); + gtot = CLIP(gtot); + btot = CLIP(btot); + } + line_red[j] = rtot; line_grn[j] = gtot; line_blue[j] = btot; @@ -767,7 +822,7 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima } if(d1x) { - transLineD1x (line_red, line_grn, line_blue, ix, image, tran, imwidth, imheight, d1xHeightOdd); + transLineD1x (line_red, line_grn, line_blue, ix, image, tran, imwidth, imheight, d1xHeightOdd, doClip); } else if(fuji) { transLineFuji (line_red, line_grn, line_blue, ix, image, tran, imheight, fw); } else { diff --git a/rtgui/crophandler.cc b/rtgui/crophandler.cc index 5ab57eacd..ecef3fa3b 100644 --- a/rtgui/crophandler.cc +++ b/rtgui/crophandler.cc @@ -313,8 +313,6 @@ void CropHandler::setDetailedCrop (IImage8* im, IImage8* imtrue, rtengine::procp cropParams = cp; colorParams = cmp; - cropPixbuf.clear (); - if (!cropimg.empty()) { cropimg.clear(); } diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index 60dd25e7e..76bf2794a 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -1053,13 +1053,6 @@ void EditorPanel::open (Thumbnail* tmb, rtengine::InitialImage* isrc) // since there was no resize event if (iareapanel->imageArea->mainCropWindow) { iareapanel->imageArea->mainCropWindow->cropHandler.newImage (ipc, false); - - // In single tab mode, the image is not always updated between switches - // normal redraw don't work, so this is the hard way - // Disabled this with Issue 2435 because it seems to work fine now -// if (!options.tabbedUI && iareapanel->imageArea->mainCropWindow->getZoomFitVal() == 1.0) { - iareapanel->imageArea->mainCropWindow->cropHandler.update(); -// } } else { Gtk::Allocation alloc; iareapanel->imageArea->on_resized (alloc); @@ -2205,7 +2198,7 @@ void EditorPanel::beforeAfterToggled () rtengine::RenderingIntent intent; ipc->getMonitorProfile(monitorProfile, intent); beforeIpc->setMonitorProfile(monitorProfile, intent); - + beforeIarea->imageArea->setPreviewHandler (beforePreviewHandler); beforeIarea->imageArea->setImProcCoordinator (beforeIpc); diff --git a/rtgui/main-cli.cc b/rtgui/main-cli.cc index 43948bae9..6643b0913 100644 --- a/rtgui/main-cli.cc +++ b/rtgui/main-cli.cc @@ -206,75 +206,6 @@ int main (int argc, char **argv) g_rename (Glib::build_filename (options.rtdir, "cache").c_str (), options.cacheBaseDir.c_str ()); } -#endif - -#ifdef WIN32 - bool consoleOpened = false; - - // suppression of annoying error boxes - SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); - - if (argc > 1 || options.rtSettings.verbose) { - Glib::ustring fname (fname_to_utf8 (argv[1])); -#if ECLIPSE_ARGS - fname = fname.substr (1, fname.length() - 2); -#endif - - if (options.rtSettings.verbose || ( !Glib::file_test (fname, Glib::FILE_TEST_EXISTS ) && !Glib::file_test (fname, Glib::FILE_TEST_IS_DIR))) { - bool stdoutRedirectedtoFile = (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0001); - bool stderrRedirectedtoFile = (GetFileType (GetStdHandle (STD_ERROR_HANDLE)) == 0x0001); - - // no console, if stdout and stderr both are redirected to file - if ( ! (stdoutRedirectedtoFile && stderrRedirectedtoFile)) { - // check if parameter -w was passed. - // We have to do that in this step, because it controls whether to open a console to show the output of following steps - bool Console = true; - - for (int i = 1; i < argc; i++) - if (!strcmp (argv[i], "-w")) { - Console = false; - break; - } - - if (Console && AllocConsole()) { - AttachConsole ( GetCurrentProcessId() ) ; - // Don't allow CTRL-C in console to terminate RT - SetConsoleCtrlHandler ( NULL, true ); - // Set title of console - char consoletitle[128]; - sprintf (consoletitle, "RawTherapee %s Console", RTVERSION); - SetConsoleTitle (consoletitle); - // increase size of screen buffer - COORD c; - c.X = 200; - c.Y = 1000; - SetConsoleScreenBufferSize ( GetStdHandle ( STD_OUTPUT_HANDLE ), c ); - // Disable console-Cursor - CONSOLE_CURSOR_INFO cursorInfo; - cursorInfo.dwSize = 100; - cursorInfo.bVisible = false; - SetConsoleCursorInfo ( GetStdHandle ( STD_OUTPUT_HANDLE ), &cursorInfo ); - - if (!stdoutRedirectedtoFile) { - freopen ( "CON", "w", stdout ) ; - } - - if (!stderrRedirectedtoFile) { - freopen ( "CON", "w", stderr ) ; - } - - freopen ( "CON", "r", stdin ) ; - - consoleOpened = true; - - // printing RT's version in every case, particularly useful for the 'verbose' mode, but also for the batch processing - std::cout << "RawTherapee, version " << RTVERSION << ", command line" << std::endl; - std::cout << "WARNING: closing this window will close RawTherapee!" << std::endl << std::endl; - } - } - } - } - #endif int ret = 0; @@ -288,16 +219,6 @@ int main (int argc, char **argv) std::cout << "Terminating without anything to do." << std::endl; } -#ifdef WIN32 - - if (consoleOpened) { - printf ("Press any key to exit RawTherapee\n"); - FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE)); - getch(); - } - -#endif - return ret; } @@ -575,11 +496,6 @@ int processLineParams ( int argc, char **argv ) } break; -#ifdef WIN32 - - case 'w': // This case is handled outside this function - break; -#endif case 'h': case '?': @@ -602,10 +518,6 @@ int processLineParams ( int argc, char **argv ) std::cout << " " << Glib::path_get_basename (argv[0]) << " -c | Convert files in batch with default parameters." << std::endl; std::cout << " " << Glib::path_get_basename (argv[0]) << " -c | Convert files in batch with your own settings." << std::endl; std::cout << std::endl; -#ifdef WIN32 - std::cout << " -w Do not open the Windows console" << std::endl; - std::cout << std::endl; -#endif std::cout << "Options:" << std::endl; std::cout << " " << Glib::path_get_basename (argv[0]) << "[-o |-O ] [-q] [-a] [-s|-S] [-p [-p ...] ] [-d] [ -j[1-100] [-js<1-3>] | [-b<8|16>] [-t[z] | [-n]] ] [-Y] [-f] -c " << std::endl; std::cout << std::endl; diff --git a/rtgui/main.cc b/rtgui/main.cc index 80f055bbf..40919b69a 100644 --- a/rtgui/main.cc +++ b/rtgui/main.cc @@ -121,6 +121,7 @@ static void myGdkLockLeave() * -3 if at least one required procparam file was not found */ int processLineParams ( int argc, char **argv ) { + int ret = 1; for ( int iArg = 1; iArg < argc; iArg++) { Glib::ustring currParam (argv[iArg]); if ( currParam.empty() ) { @@ -139,8 +140,9 @@ int processLineParams ( int argc, char **argv ) #endif case 'v': - std::cout << "Using lensfun " << LF_VERSION_MAJOR << "." << LF_VERSION_MINOR << "." << LF_VERSION_MICRO << "." << LF_VERSION_BUGFIX << std::endl; - return 0; + printf("RawTherapee, version %s\n", RTVERSION); + ret = 0; + break; #ifndef __APPLE__ // TODO agriggio - there seems to be already some "single instance app" support for OSX in rtwindow. Disabling it here until I understand how to merge the two @@ -165,34 +167,29 @@ int processLineParams ( int argc, char **argv ) case 'h': case '?': default: { - Glib::ustring pparamsExt = paramFileExtension.substr (1); - std::cout << " An advanced, cross-platform program for developing raw photos." << std::endl; + printf(" An advanced, cross-platform program for developing raw photos.\n\n"); + printf(" Website: http://www.rawtherapee.com/\n"); + printf(" Documentation: http://rawpedia.rawtherapee.com/\n"); + printf(" Forum: https://discuss.pixls.us/c/software/rawtherapee\n"); + printf(" Code and bug reports: https://github.com/Beep6581/RawTherapee\n\n"); + printf("Symbols:\n"); + printf(" indicate parameters you can change.\n\n"); + printf("Usage:\n"); + printf(" %s Start File Browser inside folder.\n",Glib::path_get_basename (argv[0]).c_str()); + printf(" %s Start Image Editor with file.\n\n",Glib::path_get_basename (argv[0]).c_str()); std::cout << std::endl; - std::cout << " Website: http://www.rawtherapee.com/" << std::endl; - std::cout << " Documentation: http://rawpedia.rawtherapee.com/" << std::endl; - std::cout << " Forum: https://discuss.pixls.us/c/software/rawtherapee" << std::endl; - std::cout << " Code and bug reports: https://github.com/Beep6581/RawTherapee" << std::endl; - std::cout << std::endl; - std::cout << "Symbols:" << std::endl; - std::cout << " indicate parameters you can change." << std::endl; - //std::cout << " [Square brackets] mean the parameter is optional." << std::endl; - //std::cout << " The pipe symbol | indicates a choice of one or the other." << std::endl; - //std::cout << " The dash symbol - denotes a range of possible values from one to the other." << std::endl; - std::cout << std::endl; - std::cout << "Usage:" << std::endl; - std::cout << " " << Glib::path_get_basename (argv[0]) << " Start File Browser inside folder." << std::endl; - std::cout << " " << Glib::path_get_basename (argv[0]) << " Start Image Editor with file." << std::endl; - std::cout << std::endl; - std::cout << "Options:" << std::endl; + printf("Options:\n"); #ifdef WIN32 - std::cout << " -w Do not open the Windows console" << std::endl; + printf(" -w Do not open the Windows console\n"); #endif - std::cout << " -v Print RawTherapee version number and exit" << std::endl; + printf(" -v Print RawTherapee version number and exit\n"); #ifndef __APPLE__ - std::cout << " -R Raise an already running RawTherapee instance (if available)" << std::endl; + printf(" -R Raise an already running RawTherapee instance (if available)\n"); #endif - std::cout << " -h -? Display this help message" << std::endl; - return -1; + printf(" -h -? Display this help message\n"); + + ret = -1; + break; } } } else { @@ -212,7 +209,7 @@ int processLineParams ( int argc, char **argv ) } } - return 1; + return ret; } @@ -517,6 +514,14 @@ int main (int argc, char **argv) options.rtSettings.lensfunDbDirectory = LENSFUN_DB_PATH; #endif + Glib::ustring fatalError; + + try { + Options::load(); + } catch (Options::Error &e) { + fatalError = e.get_msg(); + } + #ifdef WIN32 bool consoleOpened = false; @@ -525,14 +530,10 @@ int main (int argc, char **argv) SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); if (argc > 1) { - int ret = processLineParams ( argc, argv); - - if (options.rtSettings.verbose || (!remote && !Glib::file_test (argv1, Glib::FILE_TEST_EXISTS ) && !Glib::file_test (argv1, Glib::FILE_TEST_IS_DIR))) { - bool stdoutRedirectedtoFile = (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0001); - bool stderrRedirectedtoFile = (GetFileType (GetStdHandle (STD_ERROR_HANDLE)) == 0x0001); - - // no console, if stdout and stderr both are redirected to file - if ( ! (stdoutRedirectedtoFile && stderrRedirectedtoFile)) { + if (!remote && !Glib::file_test (argv1, Glib::FILE_TEST_EXISTS ) && !Glib::file_test (argv1, Glib::FILE_TEST_IS_DIR)) { + bool stdoutRedirecttoConsole = (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0000); + // open console, if stdout is invalid + if (stdoutRedirecttoConsole) { // check if parameter -w was passed. // We have to do that in this step, because it controls whether to open a console to show the output of following steps bool Console = true; @@ -562,26 +563,21 @@ int main (int argc, char **argv) cursorInfo.bVisible = false; SetConsoleCursorInfo ( GetStdHandle ( STD_OUTPUT_HANDLE ), &cursorInfo ); - if (!stdoutRedirectedtoFile) { + if (stdoutRedirecttoConsole) { // if stdout is Redirect to console, we also redirect stderr to console freopen ( "CON", "w", stdout ) ; - } - - if (!stderrRedirectedtoFile) { freopen ( "CON", "w", stderr ) ; } freopen ( "CON", "r", stdin ) ; consoleOpened = true; - - // printing RT's version in every case, particularly useful for the 'verbose' mode, but also for the batch processing - std::cout << "RawTherapee, version " << RTVERSION << std::endl; - std::cout << "WARNING: closing this window will close RawTherapee!" << std::endl << std::endl; } } } + int ret = processLineParams ( argc, argv); if ( ret <= 0 ) { + fflush(stdout); if (consoleOpened) { printf ("Press any key to exit RawTherapee\n"); FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE)); @@ -594,19 +590,11 @@ int main (int argc, char **argv) #else - if (argc > 1 || options.rtSettings.verbose) { - // printing RT's version in all case, particularly useful for the 'verbose' mode, but also for the batch processing - std::cout << "RawTherapee, version " << RTVERSION << std::endl; -#ifdef WIN32 - std::cout << "WARNING: closing this window will close RawTherapee!" << std::endl << std::endl; -#endif + if (argc > 1) { + int ret = processLineParams ( argc, argv); - if (argc > 1) { - int ret = processLineParams ( argc, argv); - - if ( ret <= 0 ) { - return ret; - } + if ( ret <= 0 ) { + return ret; } } @@ -628,14 +616,6 @@ int main (int argc, char **argv) int ret = 0; - Glib::ustring fatalError; - - try { - Options::load(); - } catch (Options::Error &e) { - fatalError = e.get_msg(); - } - gdk_threads_set_lock_functions (G_CALLBACK (myGdkLockEnter), (G_CALLBACK (myGdkLockLeave))); gdk_threads_init(); gtk_init (&argc, &argv); // use the "--g-fatal-warnings" command line flag to make warnings fatal @@ -681,6 +661,7 @@ int main (int argc, char **argv) if (consoleOpened) { printf ("Press any key to exit RawTherapee\n"); + fflush(stdout); FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE)); getch(); } diff --git a/rtgui/tonecurve.cc b/rtgui/tonecurve.cc index 043d1d055..be683c3ee 100644 --- a/rtgui/tonecurve.cc +++ b/rtgui/tonecurve.cc @@ -32,7 +32,7 @@ ToneCurve::ToneCurve () : FoldableToolPanel(this, "tonecurve", M("TP_EXPOSURE_LA auto m = ProcEventMapper::getInstance(); EvHistMatching = m->newEvent(AUTOEXP, "HISTORY_MSG_HISTMATCHING"); EvHistMatchingBatch = m->newEvent(M_VOID, "HISTORY_MSG_HISTMATCHING"); - EvClampOOG = m->newEvent(RGBCURVE, "HISTORY_MSG_CLAMPOOG"); + EvClampOOG = m->newEvent(DARKFRAME, "HISTORY_MSG_CLAMPOOG"); CurveListener::setMulti(true);