0N/A/*
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
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 *
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 *
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.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
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
0N/A// file:
0N/A//
2693N/A//---------------------------------------------------------------------------------
0N/A//
2693N/A// Little Color Management System
6271N/A// Copyright (c) 1998-2012 Marti Maria Saguer
0N/A//
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//
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//
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.
0N/A//
2693N/A//---------------------------------------------------------------------------------
0N/A//
0N/A
2693N/A#include "lcms2_internal.h"
0N/A
2693N/A// Read tags using low-level functions, provides necessary glue code to adapt versions, etc.
0N/A
2693N/A// LUT tags
2693N/Astatic const cmsTagSignature Device2PCS16[] = {cmsSigAToB0Tag, // Perceptual
2693N/A cmsSigAToB1Tag, // Relative colorimetric
2693N/A cmsSigAToB2Tag, // Saturation
2693N/A cmsSigAToB1Tag }; // Absolute colorimetric
0N/A
2693N/Astatic const cmsTagSignature Device2PCSFloat[] = {cmsSigDToB0Tag, // Perceptual
2693N/A cmsSigDToB1Tag, // Relative colorimetric
2693N/A cmsSigDToB2Tag, // Saturation
2693N/A cmsSigDToB3Tag }; // Absolute colorimetric
0N/A
2693N/Astatic const cmsTagSignature PCS2Device16[] = {cmsSigBToA0Tag, // Perceptual
2693N/A cmsSigBToA1Tag, // Relative colorimetric
2693N/A cmsSigBToA2Tag, // Saturation
2693N/A cmsSigBToA1Tag }; // Absolute colorimetric
0N/A
2693N/Astatic const cmsTagSignature PCS2DeviceFloat[] = {cmsSigBToD0Tag, // Perceptual
2693N/A cmsSigBToD1Tag, // Relative colorimetric
2693N/A cmsSigBToD2Tag, // Saturation
2693N/A cmsSigBToD3Tag }; // Absolute colorimetric
0N/A
0N/A
2693N/A// Factors to convert from 1.15 fixed point to 0..1.0 range and vice-versa
2693N/A#define InpAdj (1.0/MAX_ENCODEABLE_XYZ) // (65536.0/(65535.0*2.0))
2693N/A#define OutpAdj (MAX_ENCODEABLE_XYZ) // ((2.0*65535.0)/65536.0)
0N/A
2693N/A// Several resources for gray conversions.
2693N/Astatic const cmsFloat64Number GrayInputMatrix[] = { (InpAdj*cmsD50X), (InpAdj*cmsD50Y), (InpAdj*cmsD50Z) };
2693N/Astatic const cmsFloat64Number OneToThreeInputMatrix[] = { 1, 1, 1 };
2693N/Astatic const cmsFloat64Number PickYMatrix[] = { 0, (OutpAdj*cmsD50Y), 0 };
2693N/Astatic const cmsFloat64Number PickLstarMatrix[] = { 1, 0, 0 };
0N/A
2693N/A// Get a media white point fixing some issues found in certain old profiles
2693N/AcmsBool _cmsReadMediaWhitePoint(cmsCIEXYZ* Dest, cmsHPROFILE hProfile)
0N/A{
2693N/A cmsCIEXYZ* Tag;
0N/A
2693N/A _cmsAssert(Dest != NULL);
0N/A
2693N/A Tag = (cmsCIEXYZ*) cmsReadTag(hProfile, cmsSigMediaWhitePointTag);
0N/A
2693N/A // If no wp, take D50
2693N/A if (Tag == NULL) {
2693N/A *Dest = *cmsD50_XYZ();
2693N/A return TRUE;
1002N/A }
1002N/A
2693N/A // V2 display profiles should give D50
2693N/A if (cmsGetEncodedICCversion(hProfile) < 0x4000000) {
0N/A
2693N/A if (cmsGetDeviceClass(hProfile) == cmsSigDisplayClass) {
2693N/A *Dest = *cmsD50_XYZ();
2693N/A return TRUE;
0N/A }
0N/A }
0N/A
2693N/A // All seems ok
2693N/A *Dest = *Tag;
0N/A return TRUE;
0N/A}
0N/A
0N/A
2693N/A// Chromatic adaptation matrix. Fix some issues as well
2693N/AcmsBool _cmsReadCHAD(cmsMAT3* Dest, cmsHPROFILE hProfile)
0N/A{
2693N/A cmsMAT3* Tag;
1002N/A
2693N/A _cmsAssert(Dest != NULL);
0N/A
2693N/A Tag = (cmsMAT3*) cmsReadTag(hProfile, cmsSigChromaticAdaptationTag);
0N/A
2693N/A if (Tag != NULL) {
0N/A
2693N/A *Dest = *Tag;
2693N/A return TRUE;
0N/A }
0N/A
2693N/A // No CHAD available, default it to identity
2693N/A _cmsMAT3identity(Dest);
1002N/A
2693N/A // V2 display profiles should give D50
2693N/A if (cmsGetEncodedICCversion(hProfile) < 0x4000000) {
0N/A
2693N/A if (cmsGetDeviceClass(hProfile) == cmsSigDisplayClass) {
0N/A
2693N/A cmsCIEXYZ* White = (cmsCIEXYZ*) cmsReadTag(hProfile, cmsSigMediaWhitePointTag);
0N/A
2693N/A if (White == NULL) {
0N/A
2693N/A _cmsMAT3identity(Dest);
2693N/A return TRUE;
0N/A }
0N/A
6271N/A return _cmsAdaptationMatrix(Dest, NULL, White, cmsD50_XYZ());
0N/A }
0N/A }
0N/A
0N/A return TRUE;
0N/A}
0N/A
0N/A
2693N/A// Auxiliar, read colorants as a MAT3 structure. Used by any function that needs a matrix-shaper
0N/Astatic
2693N/AcmsBool ReadICCMatrixRGB2XYZ(cmsMAT3* r, cmsHPROFILE hProfile)
0N/A{
2693N/A cmsCIEXYZ *PtrRed, *PtrGreen, *PtrBlue;
1002N/A
2693N/A _cmsAssert(r != NULL);
0N/A
2693N/A PtrRed = (cmsCIEXYZ *) cmsReadTag(hProfile, cmsSigRedColorantTag);
2693N/A PtrGreen = (cmsCIEXYZ *) cmsReadTag(hProfile, cmsSigGreenColorantTag);
2693N/A PtrBlue = (cmsCIEXYZ *) cmsReadTag(hProfile, cmsSigBlueColorantTag);
0N/A
2693N/A if (PtrRed == NULL || PtrGreen == NULL || PtrBlue == NULL)
0N/A return FALSE;
0N/A
2693N/A _cmsVEC3init(&r -> v[0], PtrRed -> X, PtrGreen -> X, PtrBlue -> X);
2693N/A _cmsVEC3init(&r -> v[1], PtrRed -> Y, PtrGreen -> Y, PtrBlue -> Y);
2693N/A _cmsVEC3init(&r -> v[2], PtrRed -> Z, PtrGreen -> Z, PtrBlue -> Z);
0N/A
0N/A return TRUE;
0N/A}
0N/A
0N/A
2693N/A// Gray input pipeline
2693N/Astatic
2693N/AcmsPipeline* BuildGrayInputMatrixPipeline(cmsHPROFILE hProfile)
0N/A{
2693N/A cmsToneCurve *GrayTRC;
2693N/A cmsPipeline* Lut;
2693N/A cmsContext ContextID = cmsGetProfileContextID(hProfile);
2693N/A
2693N/A GrayTRC = (cmsToneCurve *) cmsReadTag(hProfile, cmsSigGrayTRCTag);
2693N/A if (GrayTRC == NULL) return NULL;
0N/A
2693N/A Lut = cmsPipelineAlloc(ContextID, 1, 3);
2693N/A if (Lut == NULL) return NULL;
2693N/A
2693N/A if (cmsGetPCS(hProfile) == cmsSigLabData) {
0N/A
2693N/A // In this case we implement the profile as an identity matrix plus 3 tone curves
2693N/A cmsUInt16Number Zero[2] = { 0x8080, 0x8080 };
2693N/A cmsToneCurve* EmptyTab;
2693N/A cmsToneCurve* LabCurves[3];
1002N/A
2693N/A EmptyTab = cmsBuildTabulatedToneCurve16(ContextID, 2, Zero);
2693N/A
2693N/A if (EmptyTab == NULL) {
2693N/A
2693N/A cmsPipelineFree(Lut);
2693N/A return NULL;
2693N/A }
0N/A
2693N/A LabCurves[0] = GrayTRC;
2693N/A LabCurves[1] = EmptyTab;
2693N/A LabCurves[2] = EmptyTab;
2693N/A
2693N/A cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 3, 1, OneToThreeInputMatrix, NULL));
2693N/A cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, 3, LabCurves));
0N/A
2693N/A cmsFreeToneCurve(EmptyTab);
0N/A
2693N/A }
2693N/A else {
2693N/A cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, 1, &GrayTRC));
2693N/A cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 3, 1, GrayInputMatrix, NULL));
0N/A }
0N/A
2693N/A return Lut;
0N/A}
0N/A
2693N/A// RGB Matrix shaper
2693N/Astatic
2693N/AcmsPipeline* BuildRGBInputMatrixShaper(cmsHPROFILE hProfile)
0N/A{
2693N/A cmsPipeline* Lut;
2693N/A cmsMAT3 Mat;
2693N/A cmsToneCurve *Shapes[3];
2693N/A cmsContext ContextID = cmsGetProfileContextID(hProfile);
2693N/A int i, j;
2693N/A
2693N/A if (!ReadICCMatrixRGB2XYZ(&Mat, hProfile)) return NULL;
2693N/A
2693N/A // XYZ PCS in encoded in 1.15 format, and the matrix output comes in 0..0xffff range, so
2693N/A // we need to adjust the output by a factor of (0x10000/0xffff) to put data in
2693N/A // a 1.16 range, and then a >> 1 to obtain 1.15. The total factor is (65536.0)/(65535.0*2)
2693N/A
2693N/A for (i=0; i < 3; i++)
2693N/A for (j=0; j < 3; j++)
2693N/A Mat.v[i].n[j] *= InpAdj;
0N/A
0N/A
2693N/A Shapes[0] = (cmsToneCurve *) cmsReadTag(hProfile, cmsSigRedTRCTag);
2693N/A Shapes[1] = (cmsToneCurve *) cmsReadTag(hProfile, cmsSigGreenTRCTag);
2693N/A Shapes[2] = (cmsToneCurve *) cmsReadTag(hProfile, cmsSigBlueTRCTag);
0N/A
2693N/A if (!Shapes[0] || !Shapes[1] || !Shapes[2])
2693N/A return NULL;
1002N/A
2693N/A Lut = cmsPipelineAlloc(ContextID, 3, 3);
2693N/A if (Lut != NULL) {
2693N/A
2693N/A cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, 3, Shapes));
2693N/A cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 3, 3, (cmsFloat64Number*) &Mat, NULL));
6271N/A
6271N/A // Note that it is certainly possible a single profile would have a LUT based
6271N/A // tag for output working in lab and a matrix-shaper for the fallback cases.
6271N/A // This is not allowed by the spec, but this code is tolerant to those cases
6271N/A if (cmsGetPCS(hProfile) == cmsSigLabData) {
6271N/A
6271N/A cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocXYZ2Lab(ContextID));
6271N/A }
6271N/A
0N/A }
0N/A
2693N/A return Lut;
2693N/A}
0N/A
6271N/A
6271N/A
6271N/A// Read the DToAX tag, adjusting the encoding of Lab or XYZ if neded
6271N/A/*static
6271N/AcmsPipeline* _cmsReadFloatInputTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat)
6271N/A{
6271N/A cmsContext ContextID = cmsGetProfileContextID(hProfile);
6271N/A cmsPipeline* Lut = cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat));
6271N/A cmsColorSpaceSignature spc = cmsGetColorSpace(hProfile);
6271N/A
6271N/A if (Lut == NULL) return NULL;
6271N/A
6271N/A // If PCS is Lab or XYZ, the floating point tag is accepting data in the space encoding,
6271N/A // and since the formatter has already accomodated to 0..1.0, we should undo this change
6271N/A if ( spc == cmsSigLabData)
6271N/A {
6271N/A cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromLabFloat(ContextID));
6271N/A }
6271N/A else
6271N/A if (spc == cmsSigXYZData)
6271N/A {
6271N/A cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromXyzFloat(ContextID));
6271N/A }
6271N/A
6271N/A return Lut;
6271N/A}
6271N/A*/
6271N/Astatic
6271N/AcmsPipeline* _cmsReadFloatInputTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat)
6271N/A{
6271N/A cmsContext ContextID = cmsGetProfileContextID(hProfile);
6271N/A cmsPipeline* Lut = cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat));
6271N/A cmsColorSpaceSignature spc = cmsGetColorSpace(hProfile);
6271N/A cmsColorSpaceSignature PCS = cmsGetPCS(hProfile);
6271N/A
6271N/A if (Lut == NULL) return NULL;
6271N/A
6271N/A // input and output of transform are in lcms 0..1 encoding. If XYZ or Lab spaces are used,
6271N/A // these need to be normalized into the appropriate ranges (Lab = 100,0,0, XYZ=1.0,1.0,1.0)
6271N/A if ( spc == cmsSigLabData)
6271N/A {
6271N/A cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToLabFloat(ContextID));
6271N/A }
6271N/A else if (spc == cmsSigXYZData)
6271N/A {
6271N/A cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToXyzFloat(ContextID));
6271N/A }
6271N/A
6271N/A if ( PCS == cmsSigLabData)
6271N/A {
6271N/A cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromLabFloat(ContextID));
6271N/A }
6271N/A else if( PCS == cmsSigXYZData)
6271N/A {
6271N/A cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromXyzFloat(ContextID));
6271N/A }
6271N/A
6271N/A return Lut;
6271N/A}
6271N/A
6271N/A
2693N/A// Read and create a BRAND NEW MPE LUT from a given profile. All stuff dependent of version, etc
2693N/A// is adjusted here in order to create a LUT that takes care of all those details
2693N/AcmsPipeline* _cmsReadInputLUT(cmsHPROFILE hProfile, int Intent)
2693N/A{
2693N/A cmsTagTypeSignature OriginalType;
2693N/A cmsTagSignature tag16 = Device2PCS16[Intent];
2693N/A cmsTagSignature tagFloat = Device2PCSFloat[Intent];
2693N/A cmsContext ContextID = cmsGetProfileContextID(hProfile);
0N/A
6271N/A // On named color, take the appropiate tag
6271N/A if (cmsGetDeviceClass(hProfile) == cmsSigNamedColorClass) {
6271N/A
6271N/A cmsPipeline* Lut;
6271N/A cmsNAMEDCOLORLIST* nc = (cmsNAMEDCOLORLIST*) cmsReadTag(hProfile, cmsSigNamedColor2Tag);
6271N/A
6271N/A if (nc == NULL) return NULL;
6271N/A
6271N/A Lut = cmsPipelineAlloc(ContextID, 0, 0);
6271N/A if (Lut == NULL) {
6271N/A cmsFreeNamedColorList(nc);
6271N/A return NULL;
6271N/A }
6271N/A
6271N/A cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageAllocNamedColor(nc, TRUE));
6271N/A cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID));
6271N/A return Lut;
6271N/A }
6271N/A
2693N/A if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence
0N/A
6271N/A // Floating point LUT are always V4, but the encoding range is no
6271N/A // longer 0..1.0, so we need to add an stage depending on the color space
6271N/A return _cmsReadFloatInputTag(hProfile, tagFloat);
2693N/A }
2693N/A
2693N/A // Revert to perceptual if no tag is found
2693N/A if (!cmsIsTag(hProfile, tag16)) {
2693N/A tag16 = Device2PCS16[0];
1002N/A }
1002N/A
2693N/A if (cmsIsTag(hProfile, tag16)) { // Is there any LUT-Based table?
0N/A
2693N/A // Check profile version and LUT type. Do the necessary adjustments if needed
0N/A
2693N/A // First read the tag
2693N/A cmsPipeline* Lut = (cmsPipeline*) cmsReadTag(hProfile, tag16);
2693N/A if (Lut == NULL) return NULL;
0N/A
2693N/A // After reading it, we have now info about the original type
2693N/A OriginalType = _cmsGetTagTrueType(hProfile, tag16);
0N/A
2693N/A // The profile owns the Lut, so we need to copy it
2693N/A Lut = cmsPipelineDup(Lut);
0N/A
2693N/A // We need to adjust data only for Lab16 on output
2693N/A if (OriginalType != cmsSigLut16Type || cmsGetPCS(hProfile) != cmsSigLabData)
2693N/A return Lut;
2693N/A
6271N/A // If the input is Lab, add also a conversion at the begin
6271N/A if (cmsGetColorSpace(hProfile) == cmsSigLabData)
6271N/A cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageAllocLabV4ToV2(ContextID));
6271N/A
2693N/A // Add a matrix for conversion V2 to V4 Lab PCS
2693N/A cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID));
2693N/A return Lut;
2693N/A }
0N/A
2693N/A // Lut was not found, try to create a matrix-shaper
0N/A
2693N/A // Check if this is a grayscale profile.
2693N/A if (cmsGetColorSpace(hProfile) == cmsSigGrayData) {
0N/A
2693N/A // if so, build appropiate conversion tables.
2693N/A // The tables are the PCS iluminant, scaled across GrayTRC
2693N/A return BuildGrayInputMatrixPipeline(hProfile);
0N/A }
0N/A
2693N/A // Not gray, create a normal matrix-shaper
2693N/A return BuildRGBInputMatrixShaper(hProfile);
0N/A}
0N/A
2693N/A// ---------------------------------------------------------------------------------------------------------------
0N/A
2693N/A// Gray output pipeline.
2693N/A// XYZ -> Gray or Lab -> Gray. Since we only know the GrayTRC, we need to do some assumptions. Gray component will be
2693N/A// given by Y on XYZ PCS and by L* on Lab PCS, Both across inverse TRC curve.
2693N/A// The complete pipeline on XYZ is Matrix[3:1] -> Tone curve and in Lab Matrix[3:1] -> Tone Curve as well.
2693N/A
2693N/Astatic
2693N/AcmsPipeline* BuildGrayOutputPipeline(cmsHPROFILE hProfile)
0N/A{
2693N/A cmsToneCurve *GrayTRC, *RevGrayTRC;
2693N/A cmsPipeline* Lut;
2693N/A cmsContext ContextID = cmsGetProfileContextID(hProfile);
2693N/A
2693N/A GrayTRC = (cmsToneCurve *) cmsReadTag(hProfile, cmsSigGrayTRCTag);
2693N/A if (GrayTRC == NULL) return NULL;
2693N/A
2693N/A RevGrayTRC = cmsReverseToneCurve(GrayTRC);
2693N/A if (RevGrayTRC == NULL) return NULL;
2693N/A
2693N/A Lut = cmsPipelineAlloc(ContextID, 3, 1);
2693N/A if (Lut == NULL) {
2693N/A cmsFreeToneCurve(RevGrayTRC);
2693N/A return NULL;
2693N/A }
2693N/A
2693N/A if (cmsGetPCS(hProfile) == cmsSigLabData) {
2693N/A
2693N/A cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 1, 3, PickLstarMatrix, NULL));
2693N/A }
2693N/A else {
2693N/A cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 1, 3, PickYMatrix, NULL));
2693N/A }
2693N/A
2693N/A cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, 1, &RevGrayTRC));
2693N/A cmsFreeToneCurve(RevGrayTRC);
2693N/A
2693N/A return Lut;
0N/A}
0N/A
0N/A
0N/A
0N/A
2693N/Astatic
2693N/AcmsPipeline* BuildRGBOutputMatrixShaper(cmsHPROFILE hProfile)
2693N/A{
2693N/A cmsPipeline* Lut;
2693N/A cmsToneCurve *Shapes[3], *InvShapes[3];
2693N/A cmsMAT3 Mat, Inv;
2693N/A int i, j;
2693N/A cmsContext ContextID = cmsGetProfileContextID(hProfile);
0N/A
2693N/A if (!ReadICCMatrixRGB2XYZ(&Mat, hProfile))
2693N/A return NULL;
0N/A
2693N/A if (!_cmsMAT3inverse(&Mat, &Inv))
2693N/A return NULL;
2693N/A
2693N/A // XYZ PCS in encoded in 1.15 format, and the matrix input should come in 0..0xffff range, so
2693N/A // we need to adjust the input by a << 1 to obtain a 1.16 fixed and then by a factor of
2693N/A // (0xffff/0x10000) to put data in 0..0xffff range. Total factor is (2.0*65535.0)/65536.0;
0N/A
2693N/A for (i=0; i < 3; i++)
2693N/A for (j=0; j < 3; j++)
2693N/A Inv.v[i].n[j] *= OutpAdj;
2693N/A
2693N/A Shapes[0] = (cmsToneCurve *) cmsReadTag(hProfile, cmsSigRedTRCTag);
2693N/A Shapes[1] = (cmsToneCurve *) cmsReadTag(hProfile, cmsSigGreenTRCTag);
2693N/A Shapes[2] = (cmsToneCurve *) cmsReadTag(hProfile, cmsSigBlueTRCTag);
0N/A
2693N/A if (!Shapes[0] || !Shapes[1] || !Shapes[2])
2693N/A return NULL;
2693N/A
2693N/A InvShapes[0] = cmsReverseToneCurve(Shapes[0]);
2693N/A InvShapes[1] = cmsReverseToneCurve(Shapes[1]);
2693N/A InvShapes[2] = cmsReverseToneCurve(Shapes[2]);
2693N/A
2693N/A if (!InvShapes[0] || !InvShapes[1] || !InvShapes[2]) {
2693N/A return NULL;
2693N/A }
0N/A
2693N/A Lut = cmsPipelineAlloc(ContextID, 3, 3);
2693N/A if (Lut != NULL) {
2693N/A
6271N/A // Note that it is certainly possible a single profile would have a LUT based
6271N/A // tag for output working in lab and a matrix-shaper for the fallback cases.
6271N/A // This is not allowed by the spec, but this code is tolerant to those cases
6271N/A if (cmsGetPCS(hProfile) == cmsSigLabData) {
6271N/A
6271N/A cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLab2XYZ(ContextID));
6271N/A }
6271N/A
2693N/A cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 3, 3, (cmsFloat64Number*) &Inv, NULL));
2693N/A cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, 3, InvShapes));
2693N/A }
0N/A
2693N/A cmsFreeToneCurveTriple(InvShapes);
2693N/A return Lut;
2693N/A}
2693N/A
6271N/A
6271N/A// Change CLUT interpolation to trilinear
6271N/Astatic
6271N/Avoid ChangeInterpolationToTrilinear(cmsPipeline* Lut)
6271N/A{
6271N/A cmsStage* Stage;
6271N/A
6271N/A for (Stage = cmsPipelineGetPtrToFirstStage(Lut);
6271N/A Stage != NULL;
6271N/A Stage = cmsStageNext(Stage)) {
6271N/A
6271N/A if (cmsStageType(Stage) == cmsSigCLutElemType) {
6271N/A
6271N/A _cmsStageCLutData* CLUT = (_cmsStageCLutData*) Stage ->Data;
6271N/A
6271N/A CLUT ->Params->dwFlags |= CMS_LERP_FLAGS_TRILINEAR;
6271N/A _cmsSetInterpolationRoutine(CLUT ->Params);
6271N/A }
6271N/A }
6271N/A}
6271N/A
6271N/A
6271N/A// Read the DToAX tag, adjusting the encoding of Lab or XYZ if neded
6271N/A/*static
6271N/AcmsPipeline* _cmsReadFloatOutputTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat)
6271N/A{
6271N/A cmsContext ContextID = cmsGetProfileContextID(hProfile);
6271N/A cmsPipeline* Lut = cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat));
6271N/A cmsColorSpaceSignature PCS = cmsGetPCS(hProfile);
6271N/A
6271N/A if (Lut == NULL) return NULL;
6271N/A
6271N/A // If PCS is Lab or XYZ, the floating point tag is accepting data in the space encoding,
6271N/A // and since the formatter has already accomodated to 0..1.0, we should undo this change
6271N/A if ( PCS == cmsSigLabData)
6271N/A {
6271N/A cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToLabFloat(ContextID));
6271N/A }
6271N/A else
6271N/A if (PCS == cmsSigXYZData)
6271N/A {
6271N/A cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToXyzFloat(ContextID));
6271N/A }
6271N/A
6271N/A return Lut;
6271N/A}*/
6271N/A
6271N/Astatic
6271N/AcmsPipeline* _cmsReadFloatOutputTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat)
6271N/A{
6271N/A cmsContext ContextID = cmsGetProfileContextID(hProfile);
6271N/A cmsPipeline* Lut = cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat));
6271N/A cmsColorSpaceSignature PCS = cmsGetPCS(hProfile);
6271N/A cmsColorSpaceSignature dataSpace = cmsGetColorSpace(hProfile);
6271N/A
6271N/A if (Lut == NULL) return NULL;
6271N/A
6271N/A // If PCS is Lab or XYZ, the floating point tag is accepting data in the space encoding,
6271N/A // and since the formatter has already accomodated to 0..1.0, we should undo this change
6271N/A if ( PCS == cmsSigLabData)
6271N/A {
6271N/A cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToLabFloat(ContextID));
6271N/A }
6271N/A else
6271N/A if (PCS == cmsSigXYZData)
6271N/A {
6271N/A cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToXyzFloat(ContextID));
6271N/A }
6271N/A
6271N/A // the output can be Lab or XYZ, in which case normalisation is needed on the end of the pipeline
6271N/A if ( dataSpace == cmsSigLabData)
6271N/A {
6271N/A cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromLabFloat(ContextID));
6271N/A }
6271N/A else if ( dataSpace == cmsSigXYZData)
6271N/A {
6271N/A cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromXyzFloat(ContextID));
6271N/A }
6271N/A
6271N/A return Lut;
6271N/A}
6271N/A
2693N/A// Create an output MPE LUT from agiven profile. Version mismatches are handled here
2693N/AcmsPipeline* _cmsReadOutputLUT(cmsHPROFILE hProfile, int Intent)
2693N/A{
2693N/A cmsTagTypeSignature OriginalType;
2693N/A cmsTagSignature tag16 = PCS2Device16[Intent];
2693N/A cmsTagSignature tagFloat = PCS2DeviceFloat[Intent];
2693N/A cmsContext ContextID = cmsGetProfileContextID(hProfile);
0N/A
2693N/A if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence
2693N/A
6271N/A // Floating point LUT are always V4
6271N/A return _cmsReadFloatOutputTag(hProfile, tagFloat);
2693N/A }
2693N/A
2693N/A // Revert to perceptual if no tag is found
2693N/A if (!cmsIsTag(hProfile, tag16)) {
2693N/A tag16 = PCS2Device16[0];
2693N/A }
0N/A
2693N/A if (cmsIsTag(hProfile, tag16)) { // Is there any LUT-Based table?
2693N/A
2693N/A // Check profile version and LUT type. Do the necessary adjustments if needed
0N/A
2693N/A // First read the tag
2693N/A cmsPipeline* Lut = (cmsPipeline*) cmsReadTag(hProfile, tag16);
2693N/A if (Lut == NULL) return NULL;
2693N/A
2693N/A // After reading it, we have info about the original type
2693N/A OriginalType = _cmsGetTagTrueType(hProfile, tag16);
0N/A
2693N/A // The profile owns the Lut, so we need to copy it
2693N/A Lut = cmsPipelineDup(Lut);
6271N/A if (Lut == NULL) return NULL;
6271N/A
6271N/A // Now it is time for a controversial stuff. I found that for 3D LUTS using
6271N/A // Lab used as indexer space, trilinear interpolation should be used
6271N/A if (cmsGetPCS(hProfile) == cmsSigLabData)
6271N/A ChangeInterpolationToTrilinear(Lut);
2693N/A
2693N/A // We need to adjust data only for Lab and Lut16 type
2693N/A if (OriginalType != cmsSigLut16Type || cmsGetPCS(hProfile) != cmsSigLabData)
2693N/A return Lut;
2693N/A
2693N/A // Add a matrix for conversion V4 to V2 Lab PCS
2693N/A cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageAllocLabV4ToV2(ContextID));
6271N/A
6271N/A // If the output is Lab, add also a conversion at the end
6271N/A if (cmsGetColorSpace(hProfile) == cmsSigLabData)
6271N/A cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID));
6271N/A
2693N/A return Lut;
2693N/A }
2693N/A
2693N/A // Lut not found, try to create a matrix-shaper
2693N/A
2693N/A // Check if this is a grayscale profile.
2693N/A if (cmsGetColorSpace(hProfile) == cmsSigGrayData) {
0N/A
2693N/A // if so, build appropiate conversion tables.
2693N/A // The tables are the PCS iluminant, scaled across GrayTRC
2693N/A return BuildGrayOutputPipeline(hProfile);
2693N/A }
2693N/A
6271N/A // Not gray, create a normal matrix-shaper, which only operates in XYZ space
2693N/A return BuildRGBOutputMatrixShaper(hProfile);
2693N/A}
2693N/A
2693N/A// ---------------------------------------------------------------------------------------------------------------
0N/A
6271N/A// Read the AToD0 tag, adjusting the encoding of Lab or XYZ if neded
6271N/Astatic
6271N/AcmsPipeline* _cmsReadFloatDevicelinkTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat)
6271N/A{
6271N/A cmsContext ContextID = cmsGetProfileContextID(hProfile);
6271N/A cmsPipeline* Lut = cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat));
6271N/A cmsColorSpaceSignature PCS = cmsGetPCS(hProfile);
6271N/A cmsColorSpaceSignature spc = cmsGetColorSpace(hProfile);
6271N/A
6271N/A if (Lut == NULL) return NULL;
6271N/A
6271N/A if (spc == cmsSigLabData)
6271N/A {
6271N/A cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToLabFloat(ContextID));
6271N/A }
6271N/A else
6271N/A if (spc == cmsSigXYZData)
6271N/A {
6271N/A cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToXyzFloat(ContextID));
6271N/A }
6271N/A
6271N/A if (PCS == cmsSigLabData)
6271N/A {
6271N/A cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromLabFloat(ContextID));
6271N/A }
6271N/A else
6271N/A if (PCS == cmsSigXYZData)
6271N/A {
6271N/A cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromXyzFloat(ContextID));
6271N/A }
6271N/A
6271N/A return Lut;
6271N/A}
6271N/A
2693N/A// This one includes abstract profiles as well. Matrix-shaper cannot be obtained on that device class. The
2693N/A// tag name here may default to AToB0
2693N/AcmsPipeline* _cmsReadDevicelinkLUT(cmsHPROFILE hProfile, int Intent)
2693N/A{
2693N/A cmsPipeline* Lut;
2693N/A cmsTagTypeSignature OriginalType;
2693N/A cmsTagSignature tag16 = Device2PCS16[Intent];
2693N/A cmsTagSignature tagFloat = Device2PCSFloat[Intent];
2693N/A cmsContext ContextID = cmsGetProfileContextID(hProfile);
2693N/A
6271N/A
6271N/A // On named color, take the appropiate tag
6271N/A if (cmsGetDeviceClass(hProfile) == cmsSigNamedColorClass) {
6271N/A
6271N/A cmsNAMEDCOLORLIST* nc = (cmsNAMEDCOLORLIST*) cmsReadTag(hProfile, cmsSigNamedColor2Tag);
6271N/A
6271N/A if (nc == NULL) return NULL;
6271N/A
6271N/A Lut = cmsPipelineAlloc(ContextID, 0, 0);
6271N/A if (Lut == NULL) {
6271N/A cmsFreeNamedColorList(nc);
6271N/A return NULL;
6271N/A }
6271N/A
6271N/A cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageAllocNamedColor(nc, FALSE));
6271N/A if (cmsGetColorSpace(hProfile) == cmsSigLabData)
6271N/A cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID));
6271N/A return Lut;
6271N/A }
6271N/A
2693N/A if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence
0N/A
6271N/A // Floating point LUT are always V
6271N/A return _cmsReadFloatDevicelinkTag(hProfile, tagFloat);
2693N/A }
2693N/A
2693N/A tagFloat = Device2PCSFloat[0];
2693N/A if (cmsIsTag(hProfile, tagFloat)) {
0N/A
2693N/A return cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat));
2693N/A }
2693N/A
2693N/A if (!cmsIsTag(hProfile, tag16)) { // Is there any LUT-Based table?
2693N/A
2693N/A tag16 = Device2PCS16[0];
2693N/A if (!cmsIsTag(hProfile, tag16)) return NULL;
2693N/A }
2693N/A
2693N/A // Check profile version and LUT type. Do the necessary adjustments if needed
0N/A
2693N/A // Read the tag
2693N/A Lut = (cmsPipeline*) cmsReadTag(hProfile, tag16);
2693N/A if (Lut == NULL) return NULL;
2693N/A
2693N/A // The profile owns the Lut, so we need to copy it
2693N/A Lut = cmsPipelineDup(Lut);
6271N/A if (Lut == NULL) return NULL;
6271N/A
6271N/A // Now it is time for a controversial stuff. I found that for 3D LUTS using
6271N/A // Lab used as indexer space, trilinear interpolation should be used
6271N/A if (cmsGetColorSpace(hProfile) == cmsSigLabData)
6271N/A ChangeInterpolationToTrilinear(Lut);
2693N/A
2693N/A // After reading it, we have info about the original type
2693N/A OriginalType = _cmsGetTagTrueType(hProfile, tag16);
0N/A
2693N/A // We need to adjust data for Lab16 on output
2693N/A if (OriginalType != cmsSigLut16Type) return Lut;
2693N/A
2693N/A // Here it is possible to get Lab on both sides
0N/A
2693N/A if (cmsGetPCS(hProfile) == cmsSigLabData) {
2693N/A cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageAllocLabV4ToV2(ContextID));
2693N/A }
2693N/A
2693N/A if (cmsGetColorSpace(hProfile) == cmsSigLabData) {
2693N/A cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID));
2693N/A }
2693N/A
2693N/A return Lut;
0N/A
0N/A
2693N/A}
0N/A
2693N/A// ---------------------------------------------------------------------------------------------------------------
0N/A
2693N/A// Returns TRUE if the profile is implemented as matrix-shaper
2693N/AcmsBool CMSEXPORT cmsIsMatrixShaper(cmsHPROFILE hProfile)
2693N/A{
2693N/A switch (cmsGetColorSpace(hProfile)) {
0N/A
2693N/A case cmsSigGrayData:
0N/A
2693N/A return cmsIsTag(hProfile, cmsSigGrayTRCTag);
2693N/A
2693N/A case cmsSigRgbData:
0N/A
2693N/A return (cmsIsTag(hProfile, cmsSigRedColorantTag) &&
2693N/A cmsIsTag(hProfile, cmsSigGreenColorantTag) &&
2693N/A cmsIsTag(hProfile, cmsSigBlueColorantTag) &&
2693N/A cmsIsTag(hProfile, cmsSigRedTRCTag) &&
2693N/A cmsIsTag(hProfile, cmsSigGreenTRCTag) &&
2693N/A cmsIsTag(hProfile, cmsSigBlueTRCTag));
0N/A
2693N/A default:
0N/A
2693N/A return FALSE;
2693N/A }
2693N/A}
0N/A
2693N/A// Returns TRUE if the intent is implemented as CLUT
6271N/AcmsBool CMSEXPORT cmsIsCLUT(cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number UsedDirection)
2693N/A{
2693N/A const cmsTagSignature* TagTable;
0N/A
2693N/A // For devicelinks, the supported intent is that one stated in the header
2693N/A if (cmsGetDeviceClass(hProfile) == cmsSigLinkClass) {
2693N/A return (cmsGetHeaderRenderingIntent(hProfile) == Intent);
2693N/A }
0N/A
2693N/A switch (UsedDirection) {
0N/A
2693N/A case LCMS_USED_AS_INPUT: TagTable = Device2PCS16; break;
2693N/A case LCMS_USED_AS_OUTPUT:TagTable = PCS2Device16; break;
0N/A
2693N/A // For proofing, we need rel. colorimetric in output. Let's do some recursion
2693N/A case LCMS_USED_AS_PROOF:
2693N/A return cmsIsIntentSupported(hProfile, Intent, LCMS_USED_AS_INPUT) &&
2693N/A cmsIsIntentSupported(hProfile, INTENT_RELATIVE_COLORIMETRIC, LCMS_USED_AS_OUTPUT);
0N/A
2693N/A default:
2693N/A cmsSignalError(cmsGetProfileContextID(hProfile), cmsERROR_RANGE, "Unexpected direction (%d)", UsedDirection);
2693N/A return FALSE;
0N/A }
0N/A
2693N/A return cmsIsTag(hProfile, TagTable[Intent]);
2693N/A
0N/A}
0N/A
0N/A
2693N/A// Return info about supported intents
2693N/AcmsBool CMSEXPORT cmsIsIntentSupported(cmsHPROFILE hProfile,
6271N/A cmsUInt32Number Intent, cmsUInt32Number UsedDirection)
0N/A{
0N/A
2693N/A if (cmsIsCLUT(hProfile, Intent, UsedDirection)) return TRUE;
0N/A
2693N/A // Is there any matrix-shaper? If so, the intent is supported. This is a bit odd, since V2 matrix shaper
2693N/A // does not fully support relative colorimetric because they cannot deal with non-zero black points, but
2693N/A // many profiles claims that, and this is certainly not true for V4 profiles. Lets answer "yes" no matter
2693N/A // the accuracy would be less than optimal in rel.col and v2 case.
0N/A
2693N/A return cmsIsMatrixShaper(hProfile);
0N/A}
0N/A
0N/A
2693N/A// ---------------------------------------------------------------------------------------------------------------
0N/A
2693N/A// Read both, profile sequence description and profile sequence id if present. Then combine both to
2693N/A// create qa unique structure holding both. Shame on ICC to store things in such complicated way.
2693N/AcmsSEQ* _cmsReadProfileSequence(cmsHPROFILE hProfile)
0N/A{
2693N/A cmsSEQ* ProfileSeq;
2693N/A cmsSEQ* ProfileId;
2693N/A cmsSEQ* NewSeq;
2693N/A cmsUInt32Number i;
2693N/A
2693N/A // Take profile sequence description first
2693N/A ProfileSeq = (cmsSEQ*) cmsReadTag(hProfile, cmsSigProfileSequenceDescTag);
2693N/A
2693N/A // Take profile sequence ID
2693N/A ProfileId = (cmsSEQ*) cmsReadTag(hProfile, cmsSigProfileSequenceIdTag);
2693N/A
2693N/A if (ProfileSeq == NULL && ProfileId == NULL) return NULL;
0N/A
2693N/A if (ProfileSeq == NULL) return cmsDupProfileSequenceDescription(ProfileId);
2693N/A if (ProfileId == NULL) return cmsDupProfileSequenceDescription(ProfileSeq);
2693N/A
2693N/A // We have to mix both together. For that they must agree
2693N/A if (ProfileSeq ->n != ProfileId ->n) return cmsDupProfileSequenceDescription(ProfileSeq);
2693N/A
2693N/A NewSeq = cmsDupProfileSequenceDescription(ProfileSeq);
0N/A
2693N/A // Ok, proceed to the mixing
6271N/A if (NewSeq != NULL) {
6271N/A for (i=0; i < ProfileSeq ->n; i++) {
2693N/A
6271N/A memmove(&NewSeq ->seq[i].ProfileID, &ProfileId ->seq[i].ProfileID, sizeof(cmsProfileID));
6271N/A NewSeq ->seq[i].Description = cmsMLUdup(ProfileId ->seq[i].Description);
6271N/A }
2693N/A }
2693N/A return NewSeq;
0N/A}
0N/A
2693N/A// Dump the contents of profile sequence in both tags (if v4 available)
2693N/AcmsBool _cmsWriteProfileSequence(cmsHPROFILE hProfile, const cmsSEQ* seq)
0N/A{
2693N/A if (!cmsWriteTag(hProfile, cmsSigProfileSequenceDescTag, seq)) return FALSE;
0N/A
2693N/A if (cmsGetProfileVersion(hProfile) >= 4.0) {
0N/A
2693N/A if (!cmsWriteTag(hProfile, cmsSigProfileSequenceIdTag, seq)) return FALSE;
1002N/A }
1002N/A
1002N/A return TRUE;
1002N/A}
1002N/A
1002N/A
2693N/A// Auxiliar, read and duplicate a MLU if found.
0N/Astatic
2693N/AcmsMLU* GetMLUFromProfile(cmsHPROFILE h, cmsTagSignature sig)
0N/A{
2693N/A cmsMLU* mlu = (cmsMLU*) cmsReadTag(h, sig);
2693N/A if (mlu == NULL) return NULL;
1002N/A
2693N/A return cmsMLUdup(mlu);
0N/A}
0N/A
2693N/A// Create a sequence description out of an array of profiles
2693N/AcmsSEQ* _cmsCompileProfileSequence(cmsContext ContextID, cmsUInt32Number nProfiles, cmsHPROFILE hProfiles[])
0N/A{
2693N/A cmsUInt32Number i;
2693N/A cmsSEQ* seq = cmsAllocProfileSequenceDescription(ContextID, nProfiles);
0N/A
2693N/A if (seq == NULL) return NULL;
0N/A
2693N/A for (i=0; i < nProfiles; i++) {
0N/A
2693N/A cmsPSEQDESC* ps = &seq ->seq[i];
2693N/A cmsHPROFILE h = hProfiles[i];
2693N/A cmsTechnologySignature* techpt;
0N/A
2693N/A cmsGetHeaderAttributes(h, &ps ->attributes);
2693N/A cmsGetHeaderProfileID(h, ps ->ProfileID.ID8);
2693N/A ps ->deviceMfg = cmsGetHeaderManufacturer(h);
2693N/A ps ->deviceModel = cmsGetHeaderModel(h);
0N/A
2693N/A techpt = (cmsTechnologySignature*) cmsReadTag(h, cmsSigTechnologyTag);
2693N/A if (techpt == NULL)
2693N/A ps ->technology = (cmsTechnologySignature) 0;
2693N/A else
2693N/A ps ->technology = *techpt;
0N/A
2693N/A ps ->Manufacturer = GetMLUFromProfile(h, cmsSigDeviceMfgDescTag);
2693N/A ps ->Model = GetMLUFromProfile(h, cmsSigDeviceModelDescTag);
2693N/A ps ->Description = GetMLUFromProfile(h, cmsSigProfileDescriptionTag);
1002N/A
2693N/A }
0N/A
2693N/A return seq;
0N/A}
0N/A
2693N/A// -------------------------------------------------------------------------------------------------------------------
0N/A
0N/A
0N/Astatic
2693N/Aconst cmsMLU* GetInfo(cmsHPROFILE hProfile, cmsInfoType Info)
0N/A{
2693N/A cmsTagSignature sig;
0N/A
2693N/A switch (Info) {
0N/A
2693N/A case cmsInfoDescription:
2693N/A sig = cmsSigProfileDescriptionTag;
2693N/A break;
0N/A
2693N/A case cmsInfoManufacturer:
2693N/A sig = cmsSigDeviceMfgDescTag;
2693N/A break;
0N/A
2693N/A case cmsInfoModel:
2693N/A sig = cmsSigDeviceModelDescTag;
2693N/A break;
0N/A
2693N/A case cmsInfoCopyright:
2693N/A sig = cmsSigCopyrightTag;
2693N/A break;
0N/A
2693N/A default: return NULL;
0N/A }
0N/A
0N/A
2693N/A return (cmsMLU*) cmsReadTag(hProfile, sig);
0N/A}
0N/A
0N/A
0N/A
2693N/AcmsUInt32Number CMSEXPORT cmsGetProfileInfo(cmsHPROFILE hProfile, cmsInfoType Info,
2693N/A const char LanguageCode[3], const char CountryCode[3],
2693N/A wchar_t* Buffer, cmsUInt32Number BufferSize)
0N/A{
2693N/A const cmsMLU* mlu = GetInfo(hProfile, Info);
2693N/A if (mlu == NULL) return 0;
0N/A
2693N/A return cmsMLUgetWide(mlu, LanguageCode, CountryCode, Buffer, BufferSize);
0N/A}
0N/A
0N/A
2693N/AcmsUInt32Number CMSEXPORT cmsGetProfileInfoASCII(cmsHPROFILE hProfile, cmsInfoType Info,
2693N/A const char LanguageCode[3], const char CountryCode[3],
2693N/A char* Buffer, cmsUInt32Number BufferSize)
0N/A{
2693N/A const cmsMLU* mlu = GetInfo(hProfile, Info);
2693N/A if (mlu == NULL) return 0;
0N/A
2693N/A return cmsMLUgetASCII(mlu, LanguageCode, CountryCode, Buffer, BufferSize);
0N/A}