diff --git a/rtengine/curves.h b/rtengine/curves.h index ff579fe79..2983a98ba 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -191,6 +191,18 @@ class CurveFactory { //static inline float gamma_srgb (double x) { return gammatab_srgb[x]; } //static inline float gamma (double x) { return gammatab[x]; } //static inline float igamma_srgb (double x) { return igammatab_srgb[x]; } + + static inline float hlcurve (const float exp_scale, const float comp, const float hlrange, float level) + { + if (comp>0.0) { + float val = level+(hlrange-65536.0); + float Y = val*exp_scale/hlrange; + float R = hlrange/(val*comp); + return log(1.0+Y*comp)*R; + } else { + return exp_scale; + } + } public: static void complexCurve (double ecomp, double black, double hlcompr, double hlcomprthresh, double shcompr, double br, double contr, double gamma_, bool igamma_, const std::vector& curvePoints, LUTu & histogram,LUTf & hlCurve, LUTf & shCurve,LUTf & outCurve, LUTu & outBeforeCCurveHistogram, int skip=1); diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index aa8529fff..331fcb751 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -246,7 +246,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { try { ipf.lab2rgb (nprevl, previmg); - } + workimg = ipf.lab2rgb (nprevl, 0,0,pW,pH, params.icm.working); } catch(char * str) { progress ("Error converting file...",0); @@ -298,6 +298,7 @@ void ImProcCoordinator::freeAll () { } else delete previmg; + delete workimg; delete shmap; for (int i=0; iverbose) printf ("setscale before lock\n"); oprevl = new LabImage (pW, pH); nprevl = new LabImage (pW, pH); previmg = new Image8 (pW, pH); + workimg = new Image8 (pW, pH); shmap = new SHMap (pW, pH, true); buffer = new int*[pH]; @@ -368,9 +370,9 @@ void ImProcCoordinator::updateHistograms (int x1, int y1, int x2, int y2) { for (int i=y1; idata[ofs++]; - int g=previmg->data[ofs++]; - int b=previmg->data[ofs++]; + int r=workimg->data[ofs++]; + int g=workimg->data[ofs++]; + int b=workimg->data[ofs++]; //bcrgbhist[(int)(0.299*r + 0.587*g + 0.114*b)]++; rhist[r]++; diff --git a/rtengine/improccoordinator.h b/rtengine/improccoordinator.h index 77a7efab4..855492272 100644 --- a/rtengine/improccoordinator.h +++ b/rtengine/improccoordinator.h @@ -46,6 +46,8 @@ class ImProcCoordinator : public StagedImageProcessor { LabImage *oprevl; LabImage *nprevl; Image8 *previmg; + Image8 *workimg; + ImageSource* imgsrc; int** buffer; diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index e8bf98697..1e86ae8bb 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -278,6 +278,11 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, LUTf & hltone if (sCurveEnabled) sCurve = new FlatCurve(params->hsvequalizer.scurve); if (vCurveEnabled) vCurve = new FlatCurve(params->hsvequalizer.vcurve); + const float exp_scale = pow (2.0, params->toneCurve.expcomp); + const float comp = (params->toneCurve.expcomp + 1.0)*params->toneCurve.hlcompr/100.0; + const float shoulder = ((65536.0/exp_scale)*(params->toneCurve.hlcomprthresh/200.0))+0.1; + const float hlrange = 65536.0-shoulder; + #pragma omp parallel for if (multiThread) for (int i=0; i=1000?1:zoom)) { cropimg_width = im->getWidth (); cropimg_height = im->getHeight (); - cropimg = new unsigned char [6*cropimg_width*cropimg_height]; + cropimg = new unsigned char [3*cropimg_width*cropimg_height]; cropimgtrue = new unsigned char [3*cropimg_width*cropimg_height]; memcpy (cropimg, im->getData(), 3*cropimg_width*cropimg_height); memcpy (cropimgtrue, imtrue->getData(), 3*cropimg_width*cropimg_height);