0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A// This file is available under and governed by the GNU General Public 0N/A// License version 2 only, as published by the Free Software Foundation. 0N/A// However, the following notice accompanied the original version of this 2693N/A//--------------------------------------------------------------------------------- 2693N/A// Little Color Management System 6271N/A// Copyright (c) 1998-2012 Marti Maria Saguer 0N/A// Permission is hereby granted, free of charge, to any person obtaining 0N/A// a copy of this software and associated documentation files (the "Software"), 0N/A// to deal in the Software without restriction, including without limitation 0N/A// the rights to use, copy, modify, merge, publish, distribute, sublicense, 0N/A// and/or sell copies of the Software, and to permit persons to whom the Software 0N/A// is furnished to do so, subject to the following conditions: 0N/A// The above copyright notice and this permission notice shall be included in 0N/A// all copies or substantial portions of the Software. 0N/A// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 0N/A// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 0N/A// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 0N/A// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 0N/A// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 0N/A// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 0N/A// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2693N/A//--------------------------------------------------------------------------------- 2693N/A// Auxiliar: append a Lab identity after the given sequence of profiles 2693N/A// and return the transform. Lab profile is closed, rest of profiles are kept open. 2693N/A // This is a rather big number and there is no need of dynamic memory 2693N/A // since we are adding a profile, 254 + 1 = 255 and this is the limit 2693N/A // Create a copy of parameters 2693N/A // Place Lab identity at chain's end. 2693N/A// Compute K -> L* relationship. Flags may include black point compensation. In this case, 2693N/A// the relationship is assumed from the profile with BPC to a black point zero. 2693N/A// Compute Black tone curve on a CMYK -> CMYK transform. This is done by 2693N/A// using the proof direction on both profiles to find K->L* relationship 2693N/A// then joining both curves. dwFlags may include black point compensation. 2693N/A // Make sure last is an output profile 2693N/A // Create individual curves. BPC works also as each K to L* is 2693N/A // computed as a BPC to zero black point in case of L* 2693N/A // Build the relationship. This effectively limits the maximum accuracy to 16 bits, but 2693N/A // since this is used on black-preserving LUTs, we are not loosing accuracy in any case 2693N/A // Make sure it is monotonic 2693N/A// Gamut LUT Creation ----------------------------------------------------------------------------------------- 0N/A// Used by gamut & softproofing 0N/A// This sampler does compute gamut boundaries by comparing original 0N/A// values with a transform going back and forth. Values above ERR_THERESHOLD 0N/A// of maximum are considered out of gamut. 0N/A // Assume in-gamut by default. 0N/A // converts from PCS to colorant. This always 0N/A // does return in-gamut values, 0N/A // Now, do the inverse, from colorant to PCS. 0N/A // Try again, but this time taking Check as input 2693N/A // Take difference of direct value 2693N/A // Take difference of converted value 2693N/A // if dE1 is small and dE2 is small, value is likely to be in gamut 2693N/A // if dE1 is small and dE2 is big, undefined. Assume in gamut 2693N/A // dE1 is big and dE2 is small, clearly out of gamut 2693N/A // dE1 is big and dE2 is also big, could be due to perceptual mapping 2693N/A// Does compute a gamut LUT going back and forth across pcs -> relativ. colorimetric intent -> pcs 2693N/A// the dE obtained is then annotated on the LUT. Values truely out of gamut are clipped to dE = 0xFFFE 2693N/A// and values changed are supposed to be handled by any gamut remapping, so, are out of gamut as well. 2693N/A// **WARNING: This algorithm does assume that gamut remapping algorithms does NOT move in-gamut colors, 2693N/A// of course, many perceptual and saturation intents does not work in such way, but relativ. ones should. 0N/A // The figure of merit. On matrix-shaper profiles, should be almost zero as 0N/A // the conversion is pretty exact. On LUT based profiles, different resolutions 0N/A // of input and output CLUT may result in differences. 2693N/A // Create a copy of parameters 6271N/A // Does create the forward step. Lab double to device 0N/A // Does create the backwards step 2693N/A // Go on, try to compute gamut LUT from PCS. This consist on a single channel containing 2693N/A // dE when doing a transform back and forth on the colorimetric intent. 0N/A // Free all needed stuff. 0N/A // And return computed hull 2693N/A// Total Area Coverage estimation ---------------------------------------------------------------- 2693N/A// This callback just accounts the maximum ink dropped in the given node. It does not populate any 2693N/A// memory, as the destination table is NULL. Its only purpose it to know the global maximum. 2693N/A // If above maximum, keep track of input values 2693N/A// Detect Total area coverage of the profile 2693N/A // TAC only works on output profiles 2693N/A // Create a fake formatter for result 2693N/A // Setup a roundtrip on perceptual intent in output profile for TAC estimation 2693N/A // For L* we only need black and white. For C* we need many points 2693N/A// Carefully, clamp on CIELab space. 2693N/A // Whole Luma surface to zero 2693N/A // Clamp white, DISCARD HIGHLIGHTS. This is done 2693N/A // in such way because icc spec doesn't allow the 2693N/A // use of L>100 as a highlight means. 2693N/A // Check out gamut prism, on a, b faces 2693N/A // Falls outside a, b limits. Transports to LCh space, 2693N/A // and then do the clipping 2693N/A if (
Lab -> a ==
0.0) {
// Is hue exactly 90? 2693N/A // atan will not work, so clamp here 2693N/A if ((h >= 0. && h <
45.) ||
2693N/A if (h >=
135. && h <
225.) {
2693N/A if (h >=
225. && h <
315.) {