Merge branch 'master' into gtk3-merge-master-b8eb349
This commit is contained in:
@@ -221,6 +221,55 @@ void Navigator::setInvalid (int fullWidth, int fullHeight)
|
||||
LAB_L->set_text (M("NAVIGATOR_NA"));
|
||||
}
|
||||
|
||||
void Navigator::getRGBText (int r, int g, int b, Glib::ustring &sR, Glib::ustring &sG, Glib::ustring &sB)
|
||||
{
|
||||
switch (currentRGBUnit) {
|
||||
case (Options::NavigatorUnit::R0_1):
|
||||
sR = Glib::ustring::format(std::fixed, std::setprecision(4), r / 255.f);
|
||||
sG = Glib::ustring::format(std::fixed, std::setprecision(4), g / 255.f);
|
||||
sB = Glib::ustring::format(std::fixed, std::setprecision(4), b / 255.f);
|
||||
break;
|
||||
case (Options::NavigatorUnit::R0_255):
|
||||
sR = Glib::ustring::format(std::fixed, std::setprecision(0), r);
|
||||
sG = Glib::ustring::format(std::fixed, std::setprecision(0), g);
|
||||
sB = Glib::ustring::format(std::fixed, std::setprecision(0), b);
|
||||
break;
|
||||
case (Options::NavigatorUnit::PERCENT):
|
||||
default:
|
||||
sR = Glib::ustring::format(std::fixed, std::setprecision(1), r * 100.f / 255.f) + Glib::ustring("%");
|
||||
sG = Glib::ustring::format(std::fixed, std::setprecision(1), g * 100.f / 255.f) + Glib::ustring("%");
|
||||
sB = Glib::ustring::format(std::fixed, std::setprecision(1), b * 100.f / 255.f) + Glib::ustring("%");
|
||||
}
|
||||
}
|
||||
|
||||
void Navigator::getHSVText (float h, float s, float v, Glib::ustring &sH, Glib::ustring &sS, Glib::ustring &sV)
|
||||
{
|
||||
switch (currentHSVUnit) {
|
||||
case (Options::NavigatorUnit::R0_1):
|
||||
sH = Glib::ustring::format(std::fixed, std::setprecision(4), h);
|
||||
sS = Glib::ustring::format(std::fixed, std::setprecision(4), s);
|
||||
sV = Glib::ustring::format(std::fixed, std::setprecision(4), v);
|
||||
break;
|
||||
case (Options::NavigatorUnit::R0_255):
|
||||
sH = Glib::ustring::format(std::fixed, std::setprecision(0), h * 255);
|
||||
sS = Glib::ustring::format(std::fixed, std::setprecision(0), s * 255);
|
||||
sV = Glib::ustring::format(std::fixed, std::setprecision(0), v * 255);
|
||||
break;
|
||||
case (Options::NavigatorUnit::PERCENT):
|
||||
default:
|
||||
sH = Glib::ustring::format(std::fixed, std::setprecision(1), h * 360.f) + Glib::ustring("\xc2\xb0");
|
||||
sS = Glib::ustring::format(std::fixed, std::setprecision(1), s * 100.f) + Glib::ustring("%");
|
||||
sV = Glib::ustring::format(std::fixed, std::setprecision(1), v * 100.f) + Glib::ustring("%");
|
||||
}
|
||||
}
|
||||
|
||||
void Navigator::getLABText (float l, float a, float b, Glib::ustring &sL, Glib::ustring &sA, Glib::ustring &sB)
|
||||
{
|
||||
sL = Glib::ustring::format(std::fixed, std::setprecision(1), l);
|
||||
sA = Glib::ustring::format(std::fixed, std::setprecision(1), a);
|
||||
sB = Glib::ustring::format(std::fixed, std::setprecision(1), b);
|
||||
}
|
||||
|
||||
// if !validPos then x/y contain the full image size
|
||||
void Navigator::pointerMoved (bool validPos, Glib::ustring profile, Glib::ustring profileW, int x, int y, int r, int g, int b)
|
||||
{
|
||||
@@ -228,54 +277,28 @@ void Navigator::pointerMoved (bool validPos, Glib::ustring profile, Glib::ustrin
|
||||
if (!validPos) {
|
||||
setInvalid (x, y);
|
||||
} else {
|
||||
Glib::ustring s1, s2, s3;
|
||||
float h, s, v;
|
||||
float LAB_a, LAB_b, LAB_l;
|
||||
|
||||
position->set_text (Glib::ustring::compose ("x: %1, y: %2", x, y));
|
||||
|
||||
switch (currentRGBUnit) {
|
||||
case (Options::NavigatorUnit::R0_1):
|
||||
R->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), r / 255.f));
|
||||
G->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), g / 255.f));
|
||||
B->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), b / 255.f));
|
||||
break;
|
||||
case (Options::NavigatorUnit::R0_255):
|
||||
R->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), r));
|
||||
G->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), g));
|
||||
B->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), b));
|
||||
break;
|
||||
case (Options::NavigatorUnit::PERCENT):
|
||||
default:
|
||||
R->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), r * 100.f / 255.f) + Glib::ustring("%"));
|
||||
G->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), g * 100.f / 255.f) + Glib::ustring("%"));
|
||||
B->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), b * 100.f / 255.f) + Glib::ustring("%"));
|
||||
break;
|
||||
}
|
||||
getRGBText (r, g, b, s1, s2, s3);
|
||||
R->set_text (s1);
|
||||
G->set_text (s2);
|
||||
B->set_text (s3);
|
||||
|
||||
float h, s, v;
|
||||
Color::rgb2hsv (r * 0xffff / 0xff, g * 0xffff / 0xff, b * 0xffff / 0xff, h, s, v);
|
||||
switch (currentHSVUnit) {
|
||||
case (Options::NavigatorUnit::R0_1):
|
||||
H->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), h));
|
||||
S->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), s));
|
||||
V->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), v));
|
||||
break;
|
||||
case (Options::NavigatorUnit::R0_255):
|
||||
H->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), h * 255));
|
||||
S->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), s * 255));
|
||||
V->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), v * 255));
|
||||
break;
|
||||
case (Options::NavigatorUnit::PERCENT):
|
||||
default:
|
||||
H->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), h * 360.f) + Glib::ustring("\xc2\xb0"));
|
||||
S->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), s * 100.f) + Glib::ustring("%"));
|
||||
V->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), v * 100.f) + Glib::ustring("%"));
|
||||
break;
|
||||
}
|
||||
getHSVText (h, s, v, s1, s2, s3);
|
||||
H->set_text (s1);
|
||||
S->set_text (s2);
|
||||
V->set_text (s3);
|
||||
|
||||
float LAB_a, LAB_b, LAB_l;
|
||||
//rgb2lab (r, g, b, LAB_l, LAB_a, LAB_b);
|
||||
rgb2lab (profile, profileW, r, g, b, LAB_l, LAB_a, LAB_b); // TODO: Really sure this function works?
|
||||
LAB_A->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), LAB_a));
|
||||
LAB_B->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), LAB_b));
|
||||
LAB_L->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), LAB_l));
|
||||
Color::rgb2lab (profile, profileW, r * 0xffff / 0xff, g * 0xffff / 0xff, b * 0xffff / 0xff, LAB_l, LAB_a, LAB_b, options.rtSettings.HistogramWorking); // TODO: Really sure this function works?
|
||||
getLABText (LAB_l, LAB_a, LAB_b, s1, s2, s3);
|
||||
LAB_L->set_text (s1);
|
||||
LAB_A->set_text (s2);
|
||||
LAB_B->set_text (s3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,6 +328,7 @@ void Navigator::cycleUnitsRGB (GdkEventButton *event) {
|
||||
B->set_text ("[%]");
|
||||
break;
|
||||
}
|
||||
sig_cycle_rgb.emit();
|
||||
}
|
||||
|
||||
void Navigator::cycleUnitsHSV (GdkEventButton *event) {
|
||||
@@ -333,151 +357,5 @@ void Navigator::cycleUnitsHSV (GdkEventButton *event) {
|
||||
V->set_text ("[%]");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Navigator::rgb2lab (Glib::ustring profile, Glib::ustring profileW, int r, int g, int b, float &LAB_l, float &LAB_a, float &LAB_b)
|
||||
{
|
||||
double xyz_rgb[3][3];
|
||||
const double ep = 216.0 / 24389.0;
|
||||
const double ka = 24389.0 / 27.0;
|
||||
|
||||
double var_R = r / 255.0;
|
||||
double var_G = g / 255.0;
|
||||
double var_B = b / 255.0;
|
||||
|
||||
Glib::ustring profileCalc;
|
||||
profileCalc = "sRGB"; //default
|
||||
|
||||
if(options.rtSettings.HistogramWorking) {
|
||||
profileCalc = profileW; //display working
|
||||
}
|
||||
|
||||
else {// if you want display = output space
|
||||
if (profile == "RT_sRGB" || profile == "RT_sRGB_gBT709" || profile == "RT_sRGB_g10") {
|
||||
profileCalc = "sRGB";
|
||||
}
|
||||
|
||||
if (profile == "ProPhoto" || profile == "RT_Large_gBT709" || profile == "RT_Large_g10" || profile == "RT_Large_gsRGB") {
|
||||
profileCalc = "ProPhoto";
|
||||
}
|
||||
|
||||
if (profile == "AdobeRGB1998" || profile == "RT_Medium_gsRGB") {
|
||||
profileCalc = "Adobe RGB";
|
||||
}
|
||||
|
||||
if (profile == "WideGamutRGB") {
|
||||
profileCalc = "WideGamut";
|
||||
}
|
||||
}
|
||||
|
||||
if(options.rtSettings.HistogramWorking) {//display working
|
||||
if (profileW == "sRGB") { //apply sRGB inverse gamma
|
||||
|
||||
if ( var_R > 0.04045 ) {
|
||||
var_R = pow ( ( ( var_R + 0.055 ) / 1.055 ), rtengine::Color::sRGBGammaCurve);
|
||||
} else {
|
||||
var_R = var_R / 12.92;
|
||||
}
|
||||
|
||||
if ( var_G > 0.04045 ) {
|
||||
var_G = pow ( ( ( var_G + 0.055 ) / 1.055 ), rtengine::Color::sRGBGammaCurve);
|
||||
} else {
|
||||
var_G = var_G / 12.92;
|
||||
}
|
||||
|
||||
if ( var_B > 0.04045 ) {
|
||||
var_B = pow ( ( ( var_B + 0.055 ) / 1.055 ), rtengine::Color::sRGBGammaCurve);
|
||||
} else {
|
||||
var_B = var_B / 12.92;
|
||||
}
|
||||
} else if (profileW == "ProPhoto") { // apply inverse gamma 1.8
|
||||
var_R = pow ( var_R, 1.8);
|
||||
var_G = pow ( var_G, 1.8);
|
||||
var_B = pow ( var_B, 1.8);
|
||||
} else { // apply inverse gamma 2.2
|
||||
var_R = pow ( var_R, 2.2);
|
||||
var_G = pow ( var_G, 2.2);
|
||||
var_B = pow ( var_B, 2.2);
|
||||
}
|
||||
} else { //display outout profile
|
||||
|
||||
if (profile == "RT_sRGB" || profile == "RT_Large_gsRGB" || profile == "RT_Medium_gsRGB") { //apply sRGB inverse gamma
|
||||
if ( var_R > 0.04045 ) {
|
||||
var_R = pow ( ( ( var_R + 0.055 ) / 1.055 ), rtengine::Color::sRGBGammaCurve);
|
||||
} else {
|
||||
var_R = var_R / 12.92;
|
||||
}
|
||||
|
||||
if ( var_G > 0.04045 ) {
|
||||
var_G = pow ( ( ( var_G + 0.055 ) / 1.055 ), rtengine::Color::sRGBGammaCurve);
|
||||
} else {
|
||||
var_G = var_G / 12.92;
|
||||
}
|
||||
|
||||
if ( var_B > 0.04045 ) {
|
||||
var_B = pow ( ( ( var_B + 0.055 ) / 1.055 ), rtengine::Color::sRGBGammaCurve);
|
||||
} else {
|
||||
var_B = var_B / 12.92;
|
||||
}
|
||||
}
|
||||
|
||||
else if (profile == "RT_sRGB_gBT709" || profile == "RT_Large_gBT709") { //
|
||||
if ( var_R > 0.0795 ) {
|
||||
var_R = pow ( ( ( var_R + 0.0954 ) / 1.0954 ), 2.2);
|
||||
} else {
|
||||
var_R = var_R / 4.5;
|
||||
}
|
||||
|
||||
if ( var_G > 0.0795 ) {
|
||||
var_G = pow ( ( ( var_G + 0.0954 ) / 1.0954 ), 2.2);
|
||||
} else {
|
||||
var_G = var_G / 4.5;
|
||||
}
|
||||
|
||||
if ( var_B > 0.0795 ) {
|
||||
var_B = pow ( ( ( var_B + 0.0954 ) / 1.0954 ), 2.2);
|
||||
} else {
|
||||
var_B = var_B / 4.5;
|
||||
}
|
||||
|
||||
} else if (profile == "ProPhoto") { // apply inverse gamma 1.8
|
||||
|
||||
var_R = pow ( var_R, 1.8);
|
||||
var_G = pow ( var_G, 1.8);
|
||||
var_B = pow ( var_B, 1.8);
|
||||
} else if (profile == "RT_sRGB_g10" || profile == "RT_Large_g10") { // apply inverse gamma 1.8
|
||||
|
||||
var_R = pow ( var_R, 1.);
|
||||
var_G = pow ( var_G, 1.);
|
||||
var_B = pow ( var_B, 1.);
|
||||
}
|
||||
|
||||
else {// apply inverse gamma 2.2
|
||||
var_R = pow ( var_R, 2.2);
|
||||
var_G = pow ( var_G, 2.2);
|
||||
var_B = pow ( var_B, 2.2);
|
||||
}
|
||||
}
|
||||
|
||||
// TMatrix wprof = rtengine::ICCStore::getInstance()->workingSpaceMatrix (profileW);
|
||||
|
||||
TMatrix wprof = rtengine::ICCStore::getInstance()->workingSpaceMatrix (profileCalc);
|
||||
|
||||
for (int m = 0; m < 3; m++)
|
||||
for (int n = 0; n < 3; n++) {
|
||||
xyz_rgb[m][n] = wprof[m][n];
|
||||
}
|
||||
|
||||
double varxx, varyy, varzz;
|
||||
double var_X = ( xyz_rgb[0][0] * var_R + xyz_rgb[0][1] * var_G + xyz_rgb[0][2] * var_B ) / Color::D50x;
|
||||
double var_Y = ( xyz_rgb[1][0] * var_R + xyz_rgb[1][1] * var_G + xyz_rgb[1][2] * var_B ) ;
|
||||
double var_Z = ( xyz_rgb[2][0] * var_R + xyz_rgb[2][1] * var_G + xyz_rgb[2][2] * var_B ) / Color::D50z;
|
||||
|
||||
varxx = var_X > ep ? cbrt(var_X) : ( ka * var_X + 16.0) / 116.0 ;
|
||||
varyy = var_Y > ep ? cbrt(var_Y) : ( ka * var_Y + 16.0) / 116.0 ;
|
||||
varzz = var_Z > ep ? cbrt(var_Z) : ( ka * var_Z + 16.0) / 116.0 ;
|
||||
LAB_l = ( 116 * varyy ) - 16;
|
||||
LAB_a = 500 * ( varxx - varyy );
|
||||
LAB_b = 200 * ( varyy - varzz );
|
||||
|
||||
sig_cycle_hsv.emit();
|
||||
}
|
||||
|
Reference in New Issue
Block a user