Custom output gamma, on behalf of Jacques; see issue #666

This commit is contained in:
Oliver Duis
2011-05-05 18:04:11 +02:00
parent a0c548fdf0
commit 22ec6055ce
22 changed files with 382 additions and 20 deletions

View File

@@ -24,16 +24,15 @@
#include <iccstore.h>
#include <processingjob.h>
#include <glibmm.h>
#include <options.h>
#include <iostream>
#include <rawimagesource.h>
#undef THREAD_PRIORITY_NORMAL
#define CLIP(a) ((a)>0?((a)<65535?(a):65535):0)
namespace rtengine {
IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* pl, bool tunnelMetaData) {
errorCode = 0;
@@ -209,7 +208,130 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
cw = params.crop.w;
ch = params.crop.h;
}
Image16* readyImg = ipf.lab2rgb16 (labView, cx, cy, cw, ch, params.icm.output);
if(params.icm.gamma != "default")
{ // if select gamma output between BT709, sRGB, linear, low, high, 2.2 , 1.8
Image16* readyImg = ipf.lab2rgb16b (labView, cx, cy, cw, ch, params.icm.output, params.icm.working, params.icm.gamma);
delete labView;
if (pl) pl->setProgress (0.70);
// get the resize parameters
int refw, refh;
double tmpScale;
if (params.resize.enabled) {
if (params.crop.enabled && params.resize.appliesTo == "Cropped area") {
// the resize values applies to the crop dimensions
refw = cw;
refh = ch;
}
else {
// the resize values applies to the image dimensions
// if a crop exists, it will be resized to the calculated scale
refw = fw;
refh = fh;
}
switch(params.resize.dataspec) {
case (1):
// Width
tmpScale = (double)params.resize.width/(double)refw;
break;
case (2):
// Height
tmpScale = (double)params.resize.height/(double)refh;
break;
case (3):
// FitBox
if ((double)refw/(double)refh > (double)params.resize.width/(double)params.resize.height) {
tmpScale = (double)params.resize.width/(double)refw;
}
else {
tmpScale = (double)params.resize.height/(double)refh;
}
break;
default:
// Scale
tmpScale = params.resize.scale;
break;
}
// resize image
if (fabs(tmpScale-1.0)>1e-5)
{
int imw, imh;
if (params.crop.enabled && params.resize.appliesTo == "Full image") {
imw = cw;
imh = ch;
}
else {
imw = refw;
imh = refh;
}
imw = (int)( (double)imw * tmpScale + 0.5 );
imh = (int)( (double)imh * tmpScale + 0.5 );
Image16* tempImage = new Image16 (imw, imh);
ipf.resize (readyImg, tempImage, tmpScale);
delete readyImg;
readyImg = tempImage;
}
}
if (tunnelMetaData)
readyImg->setMetadata (ii->getMetaData()->getExifData ());
else
readyImg->setMetadata (ii->getMetaData()->getExifData (), params.exif, params.iptc);
ProfileContent pc;
Glib::ustring chpro;
int present_space[7]={0,0,0,0,0,0,0};
std::vector<std::string> opnames = rtengine::getOutputProfiles ();
//test if files are in system
for (int j=0; j<7;j++) {
//one can modify "option" [Color Management] to adapt name of profile ih there are different for windows, MacOS, Linux ??
if(j==0) chpro=options.rtSettings.prophoto;
else if(j==1) chpro=options.rtSettings.adobe;
else if(j==2) chpro=options.rtSettings.widegamut;
else if(j==3) chpro=options.rtSettings.beta;
else if(j==4) chpro=options.rtSettings.best;
else if(j==5) chpro=options.rtSettings.bruce;
else if(j==6) chpro=options.rtSettings.srgb;
for (int i=0; i<opnames.size(); i++)
if(chpro.compare(opnames[i]) ==0) present_space[j]=1;
if (present_space[j]==0) { if (pl) pl->setProgressStr ("Missing file..");pl->setProgress (0.0);}// display file not present: not very good display information...!!
}
//choose output profile
if(params.icm.working=="ProPhoto" && present_space[0]==1) params.icm.output=options.rtSettings.prophoto;
else if(params.icm.working=="Adobe RGB" && present_space[1]==1) params.icm.output=options.rtSettings.adobe;
else if(params.icm.working=="WideGamut" && present_space[2]==1) params.icm.output=options.rtSettings.widegamut;
else if(params.icm.working=="Beta RGB" && present_space[3]==1) params.icm.output=options.rtSettings.beta;
else if(params.icm.working=="BestRGB" && present_space[4]==1) params.icm.output=options.rtSettings.best;
else if(params.icm.working=="BruceRGB" && present_space[5]==1) params.icm.output=options.rtSettings.bruce;
else params.icm.output=options.rtSettings.srgb; //if not found or choice=srgb
if (params.icm.output.compare (0, 6, "No ICM") && params.icm.output!="")
pc = iccStore->getContent (params.icm.output);
readyImg->setOutputProfile (pc.data, pc.length);
delete baseImg;
if (!job->initialImage)
ii->decreaseRef ();
delete job;
if (pl)
pl->setProgress (0.75);
return readyImg;
}
else
{//if default mode : profil = selection by choice in list (Prophoto.icm, sRGB.icm, etc., etc.) , gamma = gamma of profile
Image16* readyImg = ipf.lab2rgb16 (labView, cx, cy, cw, ch, params.icm.output);
delete labView;
if (pl) pl->setProgress (0.70);
@@ -300,6 +422,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
return readyImg;
}
}
void batchProcessingThread (ProcessingJob* job, BatchProcessingListener* bpl, bool tunnelMetaData) {