/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// This file is available under and governed by the GNU General Public
// License version 2 only, as published by the Free Software Foundation.
// However, the following notice accompanied the original version of this
// file:
//
//---------------------------------------------------------------------------------
//
// Little Color Management System
// Copyright (c) 1998-2011 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"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//---------------------------------------------------------------------------------
//
#include "lcms2_internal.h"
// Virtual (built-in) profiles
// -----------------------------------------------------------------------------------
static
{
if (DescriptionMLU)
if (CopyrightMLU)
return rc;
}
static
{
#ifdef CMS_DONT_USE_INT64
#else
#endif
if (Seq)
return rc;
}
// This function creates a profile based on White point, primaries and
// transfer functions.
const cmsCIExyY* WhitePoint,
const cmsCIExyYTRIPLE* Primaries,
{
if (!hICC) // can't allocate
return NULL;
// Implement profile using following tags:
//
// 1 cmsSigProfileDescriptionTag
// 2 cmsSigMediaWhitePointTag
// 3 cmsSigRedColorantTag
// 4 cmsSigGreenColorantTag
// 5 cmsSigBlueColorantTag
// 6 cmsSigRedTRCTag
// 7 cmsSigGreenTRCTag
// 8 cmsSigBlueTRCTag
// 9 Chromatic adaptation Tag
// This conforms a standard RGB DisplayProfile as says ICC, and then I add (As per addendum II)
// 10 cmsSigChromaticityTag
if (WhitePoint) {
// This is a V4 tag, but many CMM does read and understand it no matter which version
}
if (WhitePoint && Primaries) {
MaxWhite.x = WhitePoint -> x;
MaxWhite.y = WhitePoint -> y;
MaxWhite.Y = 1.0;
}
if (TransferFunction) {
}
if (Primaries) {
}
return hICC;
if (hICC)
return NULL;
}
const cmsCIExyYTRIPLE* Primaries,
{
}
// This function creates a profile based on White point and transfer function.
const cmsCIExyY* WhitePoint,
const cmsToneCurve* TransferFunction)
{
if (!hICC) // can't allocate
return NULL;
// Implement profile using following tags:
//
// 1 cmsSigProfileDescriptionTag
// 2 cmsSigMediaWhitePointTag
// 3 cmsSigGrayTRCTag
// This conforms a standard Gray DisplayProfile
// Fill-in the tags
if (WhitePoint) {
}
if (TransferFunction) {
}
return hICC;
if (hICC)
return NULL;
}
const cmsToneCurve* TransferFunction)
{
}
// This is a devicelink operating in the target colorspace with as many transfer functions as components
cmsToneCurve* const TransferFunctions[])
{
int nChannels;
if (!hICC)
return NULL;
// Set up channels
// Creates a Pipeline with prelinearization step only
// Copy tables to Pipeline
// Create tags
// Pipeline is already on virtual profile
// Ok, done
return hICC;
if (hICC)
return NULL;
}
cmsToneCurve* const TransferFunctions[])
{
}
// Ink-limiting algorithm
//
// Sum = C + M + Y + K
// If Sum > InkLimit
// Ratio= 1 - (Sum - InkLimit) / (C + M + Y)
// if Ratio <0
// Ratio=0
// endif
// Else
// Ratio=1
// endif
//
// C = Ratio * C
// M = Ratio * M
// Y = Ratio * Y
// K: Does not change
static
int InkLimitingSampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
{
if (Ratio < 0)
Ratio = 0;
}
else Ratio = 1;
return TRUE;
}
// This is a devicelink operating in CMYK for ink-limiting
{
int nChannels;
if (ColorSpace != cmsSigCmykData) {
return NULL;
}
}
if (!hICC) // can't allocate
return NULL;
// Creates a Pipeline with 3D grid only
// Create tags
// cmsPipeline is already on virtual profile
// Ok, done
return hICC;
return NULL;
}
cmsHPROFILE CMSEXPORT cmsCreateInkLimitingDeviceLink(cmsColorSpaceSignature ColorSpace, cmsFloat64Number Limit)
{
}
// Creates a fake Lab identity.
{
hProfile = cmsCreateRGBProfileTHR(ContextID, WhitePoint == NULL ? cmsD50_xyY() : WhitePoint, NULL, NULL);
// An identity LUT is all we need
return hProfile;
return NULL;
}
{
}
// Creates a fake Lab V4 identity.
{
hProfile = cmsCreateRGBProfileTHR(ContextID, WhitePoint == NULL ? cmsD50_xyY() : WhitePoint, NULL, NULL);
// An empty LUTs is all we need
return hProfile;
return NULL;
}
{
}
// Creates a fake XYZ identity
{
// An identity LUT is all we need
return hProfile;
return NULL;
}
{
return cmsCreateXYZProfileTHR(NULL);
}
//sRGB Curves are defined by:
//
//If R�sRGB,G�sRGB, B�sRGB < 0.04045
//
// R = R�sRGB / 12.92
// G = G�sRGB / 12.92
// B = B�sRGB / 12.92
//
//
//else if R�sRGB,G�sRGB, B�sRGB >= 0.04045
//
// R = ((R�sRGB + 0.055) / 1.055)^2.4
// G = ((G�sRGB + 0.055) / 1.055)^2.4
// B = ((B�sRGB + 0.055) / 1.055)^2.4
static
{
Parameters[0] = 2.4;
}
// Create the ICC virtual profile for sRGB space
{
{0.6400, 0.3300, 1.0},
{0.3000, 0.6000, 1.0},
{0.1500, 0.0600, 1.0}
};
cmsFreeToneCurve(Gamma22[0]);
return NULL;
}
return hsRGB;
}
{
return cmsCreate_sRGBProfileTHR(NULL);
}
typedef struct {
static
int bchswSampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
{
// Do some adjusts on LCh
// Move white point in Lab
// Back to encoded
return TRUE;
}
// Creates an abstract profile operating in Lab space for Brightness,
// contrast, Saturation and white point displacement
int nLUTPoints,
int TempSrc,
int TempDest)
{
int i;
if (!hICC) // can't allocate
return NULL;
// Creates a Pipeline with 3D grid only
return NULL;
}
// Shouldn't reach here
return NULL;
}
// Create tags
// Pipeline is already on virtual profile
// Ok, done
return hICC;
}
int TempSrc,
int TempDest)
{
return cmsCreateBCHSWabstractProfileTHR(NULL, nLUTPoints, Bright, Contrast, Hue, Saturation, TempSrc, TempDest);
}
// Creates a fake NULL profile. This profile return 1 channel as always 0.
// Is useful only for gamut checking tricks
{
if (!hProfile) // can't allocate
return NULL;
// An empty LUTs is all we need
return hProfile;
return NULL;
}
{
return cmsCreateNULLProfileTHR(NULL);
}
static
{
return (ColorSpace == cmsSigXYZData ||
ColorSpace == cmsSigLabData);
}
static
{
if (dwFlags & cmsFLAGS_GUESSDEVICECLASS) {
return;
}
return;
}
return;
}
}
}
// This function creates a named color profile dumping all the contents of transform to a single profile
// In this way, LittleCMS may be used to "group" several named color databases into a single profile.
// It has, however, several minor limitations. PCS is always Lab, which is not very critic since this
// is the normal PCS for named color profiles.
static
{
int i, nColors;
// Create an empty placeholder
// Critical information
// Tag profile with information
// Colorant count now depends on the output space
// Make sure we have proper formatters
// Apply the transfor to colorants.
for (i=0; i < nColors; i++) {
}
return hICC;
return NULL;
}
// This structure holds information about which MPU can be stored on a profile based on the version
typedef struct {
{ FALSE, 0, cmsSigLut16Type, 4, { cmsSigMatrixElemType, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType}},
{ FALSE, 0, cmsSigLut16Type, 3, { cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType}},
{ TRUE , cmsSigAToB0Tag, cmsSigLutAtoBType, 3, { cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType } },
{ TRUE , cmsSigAToB0Tag, cmsSigLutAtoBType, 3, { cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType } },
{ TRUE , cmsSigAToB0Tag, cmsSigLutAtoBType, 5, { cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType }},
{ TRUE , cmsSigBToA0Tag, cmsSigLutBtoAType, 3, { cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType }},
{ TRUE , cmsSigBToA0Tag, cmsSigLutBtoAType, 3, { cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType }},
{ TRUE , cmsSigBToA0Tag, cmsSigLutBtoAType, 5, { cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType }}
};
// Check a single entry
static
{
int n;
}
}
static
const cmsAllowedLUT* FindCombination(const cmsPipeline* Lut, cmsBool IsV4, cmsTagSignature DestinationTag)
{
for (n=0; n < SIZE_OF_ALLOWED_LUT; n++) {
}
return NULL;
}
// Does convert a transform into a device link profile
cmsHPROFILE CMSEXPORT cmsTransform2DeviceLink(cmsHTRANSFORM hTransform, cmsFloat64Number Version, cmsUInt32Number dwFlags)
{
// Get the first mpe to check for named color
// Check if is a named color transform
return CreateNamedColorDevicelink(hTransform);
}
}
// First thing to do is to get a copy of the transformation
}
// On the output side too
}
// Optimize the LUT and precalculate a devicelink
else
if (dwFlags & cmsFLAGS_FORCE_CLUT)
AllowedLUT = NULL;
else
if (AllowedLUT == NULL) {
// Try to optimize
}
// If no way, then force CLUT that for sure can be written
if (AllowedLUT == NULL) {
// Put identity curves if needed
}
// Somethings is wrong...
if (AllowedLUT == NULL) {
goto Error;
}
if (dwFlags & cmsFLAGS_8BITS_DEVICELINK)
// Tag profile with information
// Store result
}
}
}
return hProfile;
return NULL;
}