From 29061c944efd25c128152d297f414fd385d4a541 Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 13 Dec 2012 09:24:53 -0500 Subject: [PATCH] Fix for precision loss in opening 16 bit TIFF files (on behalf of Torger see issue 1642) --- rtengine/iccstore.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rtengine/iccstore.cc b/rtengine/iccstore.cc index d2c935bf8..d32b04825 100644 --- a/rtengine/iccstore.cc +++ b/rtengine/iccstore.cc @@ -380,6 +380,14 @@ cmsHPROFILE ICCStore::createFromMatrix (const double matrix[3][3], bool gamma, G // normalize gamma in RT, default (Emil's choice = sRGB) pcurve[3] = 0x2390000;//pcurve for gamma sRGB : g:2.4 s=12.92 + } else { + // lcms2 up to 2.4 has a bug with linear gamma causing precision loss (banding) + // of floating point data when a normal icc encoding of linear gamma is used + // (i e 0 table entries), but by encoding a gamma curve which is 1.0 the + // floating point path is taken within lcms2 so no precision loss occurs and + // gamma is still 1.0. + pcurve[2] = 1; + pcurve[3] = 0x1000000; //pcurve for gamma 1 } // constructing profile header