diff options
author | Marti Maria <info@littlecms.com> | 2013-03-14 10:07:38 +0100 |
---|---|---|
committer | Marti Maria <info@littlecms.com> | 2013-03-14 10:07:38 +0100 |
commit | a4847b0b3a782230f3ace3f55ca10590b40da39a (patch) | |
tree | f78351ac505a144122d4292c1a91bd0b4708c543 /src | |
parent | ceef4d3cf7c575a01dc0a84e08d6b91204522b99 (diff) | |
download | lcms2-a4847b0b3a782230f3ace3f55ca10590b40da39a.tar.gz |
Several fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/cmsgamma.c | 29 | ||||
-rw-r--r-- | src/cmsplugin.c | 8 |
2 files changed, 27 insertions, 10 deletions
diff --git a/src/cmsgamma.c b/src/cmsgamma.c index 9fdf79e..7471d25 100644 --- a/src/cmsgamma.c +++ b/src/cmsgamma.c @@ -1,7 +1,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2012 Marti Maria Saguer +// Copyright (c) 1998-2013 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), @@ -515,7 +515,7 @@ cmsFloat64Number EvalSegmentedFn(const cmsToneCurve *g, cmsFloat64Number R) // Type == 0 means segment is sampled if (g ->Segments[i].Type == 0) { - cmsFloat32Number R1 = (cmsFloat32Number) (R - g ->Segments[i].x0); + cmsFloat32Number R1 = (cmsFloat32Number) (R - g ->Segments[i].x0) / (g ->Segments[i].x1 - g ->Segments[i].x0); cmsFloat32Number Out; // Setup the table (TODO: clean that) @@ -600,20 +600,21 @@ cmsToneCurve* CMSEXPORT cmsBuildSegmentedToneCurve(cmsContext ContextID, // Use a segmented curve to store the floating point table cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurveFloat(cmsContext ContextID, cmsUInt32Number nEntries, const cmsFloat32Number values[]) { - cmsCurveSegment Seg[2]; + cmsCurveSegment Seg[3]; - // Initialize segmented curve part up to 0 - Seg[0].x0 = -1; + // A segmented tone curve should have function segments in the first and last positions + // Initialize segmented curve part up to 0 to constant value = samples[0] + Seg[0].x0 = MINUS_INF; Seg[0].x1 = 0; Seg[0].Type = 6; Seg[0].Params[0] = 1; Seg[0].Params[1] = 0; Seg[0].Params[2] = 0; - Seg[0].Params[3] = 0; + Seg[0].Params[3] = values[0]; Seg[0].Params[4] = 0; - // From zero to any + // From zero to 1 Seg[1].x0 = 0; Seg[1].x1 = 1.0; Seg[1].Type = 0; @@ -621,7 +622,19 @@ cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurveFloat(cmsContext ContextID, cm Seg[1].nGridPoints = nEntries; Seg[1].SampledPoints = (cmsFloat32Number*) values; - return cmsBuildSegmentedToneCurve(ContextID, 2, Seg); + // Final segment is constant = lastsample + Seg[2].x0 = 1.0; + Seg[2].x1 = PLUS_INF; + Seg[2].Type = 6; + + Seg[2].Params[0] = 1; + Seg[2].Params[1] = 0; + Seg[2].Params[2] = 0; + Seg[2].Params[3] = values[nEntries-1]; + Seg[2].Params[4] = 0; + + + return cmsBuildSegmentedToneCurve(ContextID, 3, Seg); } // Parametric curves diff --git a/src/cmsplugin.c b/src/cmsplugin.c index 53379eb..ff4bae7 100644 --- a/src/cmsplugin.c +++ b/src/cmsplugin.c @@ -96,10 +96,14 @@ void CMSEXPORT _cmsAdjustEndianess64(cmsUInt64Number* Result, cmsUInt64Number* pOut[0] = pIn[7]; #else - _cmsAssert(Result != NULL); - *Result = *QWord; +# ifdef CMS_DONT_USE_INT64 + (*Result)[0] = QWord[0]; + (*Result)[1] = QWord[1]; +# else + *Result = QWord; +# endif #endif } |