Merge branch 'dev' into rt-cli

This commit is contained in:
Hombre
2017-03-18 18:17:45 +01:00
156 changed files with 7335 additions and 1876 deletions

View File

@@ -98,16 +98,16 @@ Thumbnail* Thumbnail::loadFromImage (const Glib::ustring& fname, int &w, int &h,
if (inspectorMode) {
// Special case, meaning that we want a full sized thumbnail image (e.g. for the Inspector feature)
w = img->width;
h = img->height;
w = img->getWidth();
h = img->getHeight();
tpp->scale = 1.;
} else {
if (fixwh == 1) {
w = h * img->width / img->height;
tpp->scale = (double)img->height / h;
w = h * img->getWidth() / img->getHeight();
tpp->scale = (double)img->getHeight() / h;
} else {
h = w * img->height / img->width;
tpp->scale = (double)img->width / w;
h = w * img->getHeight() / img->getWidth();
tpp->scale = (double)img->getWidth() / w;
}
}
@@ -162,6 +162,7 @@ Thumbnail* Thumbnail::loadFromImage (const Glib::ustring& fname, int &w, int &h,
tpp->greenAWBMul = avg_g / double(n);
tpp->blueAWBMul = avg_b / double(n);
tpp->wbEqual = wbEq;
tpp->wbTempBias = 0.0;
cTemp.mul2temp (tpp->redAWBMul, tpp->greenAWBMul, tpp->blueAWBMul, tpp->wbEqual, tpp->autoWBTemp, tpp->autoWBGreen);
}
@@ -175,7 +176,8 @@ Thumbnail* Thumbnail::loadFromImage (const Glib::ustring& fname, int &w, int &h,
Thumbnail* Thumbnail::loadQuickFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, int &w, int &h, int fixwh, bool rotate, bool inspectorMode)
{
RawImage *ri = new RawImage(fname);
int r = ri->loadRaw(false, false);
unsigned int imageNum = 0;
int r = ri->loadRaw(false, imageNum, false);
if( r ) {
delete ri;
@@ -223,16 +225,16 @@ Thumbnail* Thumbnail::loadQuickFromRaw (const Glib::ustring& fname, RawMetaDataL
if (inspectorMode) {
// Special case, meaning that we want a full sized thumbnail image (e.g. for the Inspector feature)
w = img->width;
h = img->height;
w = img->getWidth();
h = img->getHeight();
tpp->scale = 1.;
} else {
if (fixwh == 1) {
w = h * img->width / img->height;
tpp->scale = (double)img->height / h;
w = h * img->getWidth() / img->getHeight();
tpp->scale = (double)img->getHeight() / h;
} else {
h = w * img->height / img->width;
tpp->scale = (double)img->width / w;
h = w * img->getHeight() / img->getWidth();
tpp->scale = (double)img->getWidth() / w;
}
}
@@ -260,8 +262,8 @@ Thumbnail* Thumbnail::loadQuickFromRaw (const Glib::ustring& fname, RawMetaDataL
if (suffix != "mos" && suffix != "mef" && suffix != "iiq") {
tpp->thumbImg->rotate(ri->get_rotateDegree());
// width/height may have changed after rotating
w = tpp->thumbImg->width;
h = tpp->thumbImg->height;
w = tpp->thumbImg->getWidth();
h = tpp->thumbImg->getHeight();
}
}
@@ -289,7 +291,9 @@ RawMetaDataLocation Thumbnail::loadMetaDataFromRaw (const Glib::ustring& fname)
rml.ciffLength = -1;
RawImage ri(fname);
int r = ri.loadRaw(false);
unsigned int imageNum = 0;
int r = ri.loadRaw(false, imageNum);
if( !r ) {
rml.exifBase = ri.get_exifBase();
@@ -300,10 +304,12 @@ RawMetaDataLocation Thumbnail::loadMetaDataFromRaw (const Glib::ustring& fname)
return rml;
}
Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, int &w, int &h, int fixwh, double wbEq, bool rotate)
Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, int &w, int &h, int fixwh, double wbEq, bool rotate, int imageNum)
{
RawImage *ri = new RawImage (fname);
int r = ri->loadRaw(1, 0);
unsigned int tempImageNum = 0;
int r = ri->loadRaw(1, tempImageNum, 0);
if( r ) {
delete ri;
@@ -735,6 +741,7 @@ Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocati
tpp->greenAWBMul = ri->get_rgb_cam(1, 0) * reds + ri->get_rgb_cam(1, 1) * greens + ri->get_rgb_cam(1, 2) * blues;
tpp->blueAWBMul = ri->get_rgb_cam(2, 0) * reds + ri->get_rgb_cam(2, 1) * greens + ri->get_rgb_cam(2, 2) * blues;
tpp->wbEqual = wbEq;
tpp->wbTempBias = 0.0;
ColorTemp cTemp;
cTemp.mul2temp(tpp->redAWBMul, tpp->greenAWBMul, tpp->blueAWBMul, tpp->wbEqual, tpp->autoWBTemp, tpp->autoWBGreen);
@@ -776,7 +783,7 @@ Thumbnail::Thumbnail () :
camProfile(nullptr), thumbImg(nullptr),
camwbRed(1.0), camwbGreen(1.0), camwbBlue(1.0),
redAWBMul(-1.0), greenAWBMul(-1.0), blueAWBMul(-1.0),
autoWBTemp(2700), autoWBGreen(1.0), wbEqual(-1.0),
autoWBTemp(2700), autoWBGreen(1.0), wbEqual(-1.0), wbTempBias(0.0),
embProfileLength(0), embProfileData(nullptr), embProfile(nullptr),
redMultiplier(1.0), greenMultiplier(1.0), blueMultiplier(1.0),
defGain(1.0),
@@ -810,9 +817,9 @@ IImage8* Thumbnail::quickProcessImage (const procparams::ProcParams& params, int
if (params.coarse.rotate == 90 || params.coarse.rotate == 270) {
rwidth = rheight;
rheight = thumbImg->height * rwidth / thumbImg->width;
rheight = thumbImg->getHeight() * rwidth / thumbImg->getWidth();
} else {
rwidth = thumbImg->width * rheight / thumbImg->height;
rwidth = thumbImg->getWidth() * rheight / thumbImg->getHeight();
}
Image8* baseImg = resizeTo<Image8>(rwidth, rheight, interp, thumbImg);
@@ -839,11 +846,13 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei
BENCHFUN
// check if the WB's equalizer value has changed
if (wbEqual < (params.wb.equal - 5e-4) || wbEqual > (params.wb.equal + 5e-4)) {
if (wbEqual < (params.wb.equal - 5e-4) || wbEqual > (params.wb.equal + 5e-4) || wbTempBias < (params.wb.tempBias - 5e-4) || wbTempBias > (params.wb.tempBias + 5e-4)) {
wbEqual = params.wb.equal;
wbTempBias = params.wb.tempBias;
// recompute the autoWB
ColorTemp cTemp;
cTemp.mul2temp (redAWBMul, greenAWBMul, blueAWBMul, wbEqual, autoWBTemp, autoWBGreen);
autoWBTemp += autoWBTemp * wbTempBias;
}
// compute WB multipliers
@@ -889,9 +898,9 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei
if (params.coarse.rotate == 90 || params.coarse.rotate == 270) {
rwidth = rheight;
rheight = int(size_t(thumbImg->height) * size_t(rwidth) / size_t(thumbImg->width));
rheight = int(size_t(thumbImg->getHeight()) * size_t(rwidth) / size_t(thumbImg->getWidth()));
} else {
rwidth = int(size_t(thumbImg->width) * size_t(rheight) / size_t(thumbImg->height));
rwidth = int(size_t(thumbImg->getWidth()) * size_t(rheight) / size_t(thumbImg->getHeight()));
}
@@ -899,8 +908,8 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei
if (params.coarse.rotate) {
baseImg->rotate (params.coarse.rotate);
rwidth = baseImg->width;
rheight = baseImg->height;
rwidth = baseImg->getWidth();
rheight = baseImg->getHeight();
}
if (params.coarse.hflip) {
@@ -940,12 +949,12 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei
StdImageSource::colorSpaceConversion (baseImg, params.icm, embProfile, thumbImg->getSampleFormat());
}
int fw = baseImg->width;
int fh = baseImg->height;
int fw = baseImg->getWidth();
int fh = baseImg->getHeight();
//ColorTemp::CAT02 (baseImg, &params) ;//perhaps not good!
ImProcFunctions ipf (&params, false);
ipf.setScale (sqrt(double(fw * fw + fh * fh)) / sqrt(double(thumbImg->width * thumbImg->width + thumbImg->height * thumbImg->height))*scale);
ipf.setScale (sqrt(double(fw * fw + fh * fh)) / sqrt(double(thumbImg->getWidth() * thumbImg->getWidth() + thumbImg->getHeight() * thumbImg->getHeight()))*scale);
ipf.updateColorProfiles (options.rtSettings.monitorProfile, options.rtSettings.monitorIntent, false, false);
LUTu hist16 (65536);
@@ -1206,9 +1215,9 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei
// calculate scale
if (params.coarse.rotate == 90 || params.coarse.rotate == 270) {
myscale = scale * thumbImg->width / fh;
myscale = scale * thumbImg->getWidth() / fh;
} else {
myscale = scale * thumbImg->height / fh;
myscale = scale * thumbImg->getHeight() / fh;
}
myscale = 1.0 / myscale;
@@ -1238,9 +1247,9 @@ int Thumbnail::getImageWidth (const procparams::ProcParams& params, int rheight,
int rwidth;
if (params.coarse.rotate == 90 || params.coarse.rotate == 270) {
ratio = (float)(thumbImg->height) / (float)(thumbImg->width);
ratio = (float)(thumbImg->getHeight()) / (float)(thumbImg->getWidth());
} else {
ratio = (float)(thumbImg->width) / (float)(thumbImg->height);
ratio = (float)(thumbImg->getWidth()) / (float)(thumbImg->getHeight());
}
rwidth = (int)(ratio * (float)rheight);
@@ -1251,8 +1260,8 @@ int Thumbnail::getImageWidth (const procparams::ProcParams& params, int rheight,
void Thumbnail::getDimensions (int& w, int& h, double& scaleFac)
{
if (thumbImg) {
w = thumbImg->width;
h = thumbImg->height;
w = thumbImg->getWidth();
h = thumbImg->getHeight();
scaleFac = scale;
} else {
w = 0;
@@ -1272,15 +1281,17 @@ void Thumbnail::getCamWB (double& temp, double& green)
green = currWB.getGreen ();
}
void Thumbnail::getAutoWB (double& temp, double& green, double equal)
void Thumbnail::getAutoWB (double& temp, double& green, double equal, double tempBias)
{
if (equal != wbEqual) {
if (equal != wbEqual || tempBias != wbTempBias) {
// compute the values depending on equal
ColorTemp cTemp;
wbEqual = equal;
wbTempBias = tempBias;
// compute autoWBTemp and autoWBGreen
cTemp.mul2temp(redAWBMul, greenAWBMul, blueAWBMul, wbEqual, autoWBTemp, autoWBGreen);
autoWBTemp += autoWBTemp * tempBias;
}
temp = autoWBTemp;
@@ -1314,11 +1325,11 @@ void Thumbnail::getSpotWB (const procparams::ProcParams& params, int xp, int yp,
points.push_back (Coord2D (j, i));
}
int fw = thumbImg->width, fh = thumbImg->height;
int fw = thumbImg->getWidth(), fh = thumbImg->getHeight();
if (params.coarse.rotate == 90 || params.coarse.rotate == 270) {
fw = thumbImg->height;
fh = thumbImg->width;
fw = thumbImg->getHeight();
fh = thumbImg->getWidth();
}
ImProcFunctions ipf (&params, false);
@@ -1343,8 +1354,8 @@ void Thumbnail::getSpotWB (const procparams::ProcParams& params, int xp, int yp,
void Thumbnail::transformPixel (int x, int y, int tran, int& tx, int& ty)
{
int W = thumbImg->width;
int H = thumbImg->height;
int W = thumbImg->getWidth();
int H = thumbImg->getHeight();
int sw = W, sh = H;
if ((tran & TR_ROT) == TR_R90 || (tran & TR_ROT) == TR_R270) {
@@ -1386,12 +1397,12 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width)
return nullptr;
}
if (thumbImg->width < trim_width) {
if (thumbImg->getWidth() < trim_width) {
return nullptr;
}
// to utilize the 8 bit color range of the thumbnail we brighten it and apply gamma correction
unsigned char* tmpdata = new unsigned char[thumbImg->height * trim_width];
unsigned char* tmpdata = new unsigned char[thumbImg->getHeight() * trim_width];
int ix = 0, max;
if (gammaCorrected) {
@@ -1417,7 +1428,7 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width)
}
// Go down till we cut off that many pixels
unsigned long cutoff = thumbImg->height * thumbImg->height * 4 * BurnOffPct;
unsigned long cutoff = thumbImg->getHeight() * thumbImg->getHeight() * 4 * BurnOffPct;
int max_;
unsigned long sum = 0;
@@ -1434,8 +1445,8 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width)
if (thumbImg->getType() == sImage8) {
Image8 *image = static_cast<Image8*>(thumbImg);
for (int i = 0; i < thumbImg->height; i++)
for (int j = (thumbImg->width - trim_width) / 2; j < trim_width + (thumbImg->width - trim_width) / 2; j++) {
for (int i = 0; i < thumbImg->getHeight(); i++)
for (int j = (thumbImg->getWidth() - trim_width) / 2; j < trim_width + (thumbImg->getWidth() - trim_width) / 2; j++) {
unsigned short r_, g_, b_;
image->convertTo(image->r(i, j), r_);
image->convertTo(image->g(i, j), g_);
@@ -1448,8 +1459,8 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width)
} else if (thumbImg->getType() == sImage16) {
Image16 *image = static_cast<Image16*>(thumbImg);
for (int i = 0; i < thumbImg->height; i++)
for (int j = (thumbImg->width - trim_width) / 2; j < trim_width + (thumbImg->width - trim_width) / 2; j++) {
for (int i = 0; i < thumbImg->getHeight(); i++)
for (int j = (thumbImg->getWidth() - trim_width) / 2; j < trim_width + (thumbImg->getWidth() - trim_width) / 2; j++) {
unsigned short r_, g_, b_;
image->convertTo(image->r(i, j), r_);
image->convertTo(image->g(i, j), g_);
@@ -1462,8 +1473,8 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width)
} else if (thumbImg->getType() == sImagefloat) {
Imagefloat *image = static_cast<Imagefloat*>(thumbImg);
for (int i = 0; i < thumbImg->height; i++)
for (int j = (thumbImg->width - trim_width) / 2; j < trim_width + (thumbImg->width - trim_width) / 2; j++) {
for (int i = 0; i < thumbImg->getHeight(); i++)
for (int j = (thumbImg->getWidth() - trim_width) / 2; j < trim_width + (thumbImg->getWidth() - trim_width) / 2; j++) {
unsigned short r_, g_, b_;
image->convertTo(image->r(i, j), r_);
image->convertTo(image->g(i, j), g_);
@@ -1482,8 +1493,8 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width)
Image8 *image = static_cast<Image8*>(thumbImg);
unsigned char max_ = 0;
for (int row = 0; row < image->height; row++)
for (int col = 0; col < image->width; col++) {
for (int row = 0; row < image->getHeight(); row++)
for (int col = 0; col < image->getWidth(); col++) {
if (image->r(row, col) > max_) {
max_ = image->r(row, col);
}
@@ -1506,8 +1517,8 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width)
scaleForSave = 65535 * 8192 / max;
// Correction and gamma to 8 Bit
for (int i = 0; i < image->height; i++)
for (int j = (image->width - trim_width) / 2; j < trim_width + (image->width - trim_width) / 2; j++) {
for (int i = 0; i < image->getHeight(); i++)
for (int j = (image->getWidth() - trim_width) / 2; j < trim_width + (image->getWidth() - trim_width) / 2; j++) {
unsigned short rtmp, gtmp, btmp;
image->convertTo(image->r(i, j), rtmp);
image->convertTo(image->g(i, j), gtmp);
@@ -1521,8 +1532,8 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width)
Image16 *image = static_cast<Image16*>(thumbImg);
unsigned short max_ = 0;
for (int row = 0; row < image->height; row++)
for (int col = 0; col < image->width; col++) {
for (int row = 0; row < image->getHeight(); row++)
for (int col = 0; col < image->getWidth(); col++) {
if (image->r(row, col) > max_) {
max_ = image->r(row, col);
}
@@ -1545,8 +1556,8 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width)
scaleForSave = 65535 * 8192 / max;
// Correction and gamma to 8 Bit
for (int i = 0; i < image->height; i++)
for (int j = (image->width - trim_width) / 2; j < trim_width + (image->width - trim_width) / 2; j++) {
for (int i = 0; i < image->getHeight(); i++)
for (int j = (image->getWidth() - trim_width) / 2; j < trim_width + (image->getWidth() - trim_width) / 2; j++) {
unsigned short rtmp, gtmp, btmp;
image->convertTo(image->r(i, j), rtmp);
image->convertTo(image->g(i, j), gtmp);
@@ -1560,8 +1571,8 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width)
Imagefloat *image = static_cast<Imagefloat*>(thumbImg);
float max_ = 0.f;
for (int row = 0; row < image->height; row++)
for (int col = 0; col < image->width; col++) {
for (int row = 0; row < image->getHeight(); row++)
for (int col = 0; col < image->getWidth(); col++) {
if (image->r(row, col) > max_) {
max_ = image->r(row, col);
}
@@ -1584,8 +1595,8 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width)
scaleForSave = 65535 * 8192 / max;
// Correction and gamma to 8 Bit
for (int i = 0; i < image->height; i++)
for (int j = (image->width - trim_width) / 2; j < trim_width + (image->width - trim_width) / 2; j++) {
for (int i = 0; i < image->getHeight(); i++)
for (int j = (image->getWidth() - trim_width) / 2; j < trim_width + (image->getWidth() - trim_width) / 2; j++) {
unsigned short rtmp, gtmp, btmp;
image->convertTo(image->r(i, j), rtmp);
image->convertTo(image->g(i, j), gtmp);
@@ -1617,7 +1628,7 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width)
}
if (cdf_min != -1) {
hist[i] = (cdf - cdf_min) * 255 / ((thumbImg->height * trim_width) - cdf_min);
hist[i] = (cdf - cdf_min) * 255 / ((thumbImg->getHeight() * trim_width) - cdf_min);
}
}
@@ -1645,8 +1656,8 @@ bool Thumbnail::writeImage (const Glib::ustring& fname, int format)
fwrite (thumbImg->getType(), sizeof (char), strlen(thumbImg->getType()), f);
fputc ('\n', f);
guint32 w = guint32(thumbImg->width);
guint32 h = guint32(thumbImg->height);
guint32 w = guint32(thumbImg->getWidth());
guint32 h = guint32(thumbImg->getHeight());
fwrite (&w, sizeof (guint32), 1, f);
fwrite (&h, sizeof (guint32), 1, f);