From 89c9d176b4349367ecd45f85b94aea3bf6f372c9 Mon Sep 17 00:00:00 2001 From: Marti Maria Date: Sun, 24 Jul 2022 10:42:59 +0200 Subject: Fix CMYK range on fast float plugin Range should be in % --- plugins/fast_float/src/fast_float_tethra.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'plugins') diff --git a/plugins/fast_float/src/fast_float_tethra.c b/plugins/fast_float/src/fast_float_tethra.c index 72c872b..ef4fccf 100644 --- a/plugins/fast_float/src/fast_float_tethra.c +++ b/plugins/fast_float/src/fast_float_tethra.c @@ -273,9 +273,29 @@ cmsBool OptimizeCLUTRGBTransform(_cmsTransform2Fn* TransformFn, // Add the CLUT to the destination LUT cmsPipelineInsertStage(OptimizedLUT, cmsAT_BEGIN, OptimizedCLUTmpe); + // If output is CMYK, add a conversion stage to get % + if (T_COLORSPACE(*OutputFormat) == PT_CMYK) { + + static const cmsFloat64Number mat[] = { 100.0, 0, 0, 0, + 0, 100.0, 0, 0, + 0, 0, 100.0, 0, + 0, 0, 0, 100.0 }; + + cmsStage* percent = cmsStageAllocMatrix(ContextID, 4, 4, mat, NULL); + if (percent == NULL) goto Error; + + cmsPipelineInsertStage(OriginalLut, cmsAT_END, percent); + } + // Resample the LUT if (!cmsStageSampleCLutFloat(OptimizedCLUTmpe, XFormSampler, (void*)OriginalLut, 0)) goto Error; + + if (T_COLORSPACE(*OutputFormat) == PT_CMYK) { + + cmsPipelineUnlinkStage(OriginalLut, cmsAT_END, NULL); + } + // Set the evaluator, copy parameters data = (_cmsStageCLutData*) cmsStageData(OptimizedCLUTmpe); -- cgit v1.2.3