Cancelling a 32 bits Tiff workaround, now the Gamma value from embedded
ICC profile is correctly handled
This commit is contained in:
parent
a989d440b1
commit
81c5b1ca41
@ -771,39 +771,39 @@ int ImageIO::loadTIFF (Glib::ustring fname)
|
|||||||
* We could use the min/max values set in TIFFTAG_SMINSAMPLEVALUE and
|
* We could use the min/max values set in TIFFTAG_SMINSAMPLEVALUE and
|
||||||
* TIFFTAG_SMAXSAMPLEVALUE, but for now, we normalize the image to the
|
* TIFFTAG_SMAXSAMPLEVALUE, but for now, we normalize the image to the
|
||||||
* effective minimum and maximum values
|
* effective minimum and maximum values
|
||||||
*
|
*/
|
||||||
printf("Informations de \"%s\":\n", fname.c_str());
|
if (options.rtSettings.verbose) {
|
||||||
uint16 tiffDefaultScale, tiffBaselineExposure, tiffLinearResponseLimit;
|
printf("Informations of \"%s\":\n", fname.c_str());
|
||||||
if (TIFFGetField(in, TIFFTAG_DEFAULTSCALE, &tiffDefaultScale)) {
|
uint16 tiffDefaultScale, tiffBaselineExposure, tiffLinearResponseLimit;
|
||||||
printf(" DefaultScale: %d\n", tiffDefaultScale);
|
if (TIFFGetField(in, TIFFTAG_DEFAULTSCALE, &tiffDefaultScale)) {
|
||||||
}
|
printf(" DefaultScale: %d\n", tiffDefaultScale);
|
||||||
else
|
}
|
||||||
printf(" No DefaultScale value!\n");
|
else
|
||||||
if (TIFFGetField(in, TIFFTAG_BASELINEEXPOSURE, &tiffBaselineExposure)) {
|
printf(" No DefaultScale value!\n");
|
||||||
printf(" BaselineExposure: %d\n", tiffBaselineExposure);
|
if (TIFFGetField(in, TIFFTAG_BASELINEEXPOSURE, &tiffBaselineExposure)) {
|
||||||
}
|
printf(" BaselineExposure: %d\n", tiffBaselineExposure);
|
||||||
else
|
}
|
||||||
printf(" No BaselineExposure value!\n");
|
else
|
||||||
if (TIFFGetField(in, TIFFTAG_LINEARRESPONSELIMIT, &tiffLinearResponseLimit)) {
|
printf(" No BaselineExposure value!\n");
|
||||||
printf(" LinearResponseLimit: %d\n", tiffLinearResponseLimit);
|
if (TIFFGetField(in, TIFFTAG_LINEARRESPONSELIMIT, &tiffLinearResponseLimit)) {
|
||||||
}
|
printf(" LinearResponseLimit: %d\n", tiffLinearResponseLimit);
|
||||||
else
|
}
|
||||||
printf(" No LinearResponseLimit value!\n");
|
else
|
||||||
|
printf(" No LinearResponseLimit value!\n");
|
||||||
|
|
||||||
uint16 tiffMinValue, tiffMaxValue;
|
uint16 tiffMinValue, tiffMaxValue;
|
||||||
if (TIFFGetField(in, TIFFTAG_SMINSAMPLEVALUE, &tiffMinValue)) {
|
if (TIFFGetField(in, TIFFTAG_SMINSAMPLEVALUE, &tiffMinValue)) {
|
||||||
printf(" MinValue: %d\n", tiffMinValue);
|
printf(" MinValue: %d\n", tiffMinValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf(" No minimum value!\n");
|
||||||
|
if (TIFFGetField(in, TIFFTAG_SMAXSAMPLEVALUE, &tiffMaxValue)) {
|
||||||
|
printf(" MaxValue: %d\n\n", tiffMaxValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf(" No maximum value!\n\n");
|
||||||
|
printf(" Those values are not taken into account, the image data are normalized to a [0;1] range\n\n");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
printf(" No minimum value!\n");
|
|
||||||
if (TIFFGetField(in, TIFFTAG_SMAXSAMPLEVALUE, &tiffMaxValue)) {
|
|
||||||
printf(" MaxValue: %d\n\n", tiffMaxValue);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
printf(" No maximum value!\n\n");
|
|
||||||
printf("\n");
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
char* profdata;
|
char* profdata;
|
||||||
deleteLoadedProfileData();
|
deleteLoadedProfileData();
|
||||||
@ -811,30 +811,8 @@ int ImageIO::loadTIFF (Glib::ustring fname)
|
|||||||
|
|
||||||
if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &loadedProfileLength, &profdata)) {
|
if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &loadedProfileLength, &profdata)) {
|
||||||
embProfile = cmsOpenProfileFromMem (profdata, loadedProfileLength);
|
embProfile = cmsOpenProfileFromMem (profdata, loadedProfileLength);
|
||||||
|
loadedProfileData = new char [loadedProfileLength];
|
||||||
// For 32 bits floating point images, gamma is forced to linear in embedded ICC profiles
|
memcpy (loadedProfileData, profdata, loadedProfileLength);
|
||||||
if ( sampleFormat & (IIOSF_LOGLUV24 | IIOSF_LOGLUV32 | IIOSF_FLOAT) ) {
|
|
||||||
// Modifying the gammaTRG tags
|
|
||||||
cmsWriteTag(embProfile, cmsSigGreenTRCTag, (void*)Color::linearGammaTRC );
|
|
||||||
cmsWriteTag(embProfile, cmsSigRedTRCTag, (void*)Color::linearGammaTRC );
|
|
||||||
cmsWriteTag(embProfile, cmsSigBlueTRCTag, (void*)Color::linearGammaTRC );
|
|
||||||
|
|
||||||
// Saving the profile in the memory
|
|
||||||
cmsUInt32Number bytesNeeded = 0;
|
|
||||||
cmsSaveProfileToMem(embProfile, 0, &bytesNeeded);
|
|
||||||
|
|
||||||
if (bytesNeeded > 0) {
|
|
||||||
loadedProfileData = new char[bytesNeeded + 1];
|
|
||||||
cmsSaveProfileToMem(embProfile, loadedProfileData, &bytesNeeded);
|
|
||||||
}
|
|
||||||
|
|
||||||
loadedProfileLength = (int)bytesNeeded;
|
|
||||||
} else {
|
|
||||||
// Saving the profile in the memory as is
|
|
||||||
loadedProfileData = new char [loadedProfileLength];
|
|
||||||
memcpy (loadedProfileData, profdata, loadedProfileLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
embProfile = NULL;
|
embProfile = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user