< prev index next >
src/java.desktop/share/native/liblcms/cmsio1.c
Print this page
*** 28,38 ****
// file:
//
//---------------------------------------------------------------------------------
//
// Little Color Management System
! // Copyright (c) 1998-2012 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,
--- 28,38 ----
// file:
//
//---------------------------------------------------------------------------------
//
// Little Color Management System
! // Copyright (c) 1998-2016 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,
*** 155,165 ****
return TRUE;
}
! // Auxiliar, read colorants as a MAT3 structure. Used by any function that needs a matrix-shaper
static
cmsBool ReadICCMatrixRGB2XYZ(cmsMAT3* r, cmsHPROFILE hProfile)
{
cmsCIEXYZ *PtrRed, *PtrGreen, *PtrBlue;
--- 155,165 ----
return TRUE;
}
! // Auxiliary, read colorants as a MAT3 structure. Used by any function that needs a matrix-shaper
static
cmsBool ReadICCMatrixRGB2XYZ(cmsMAT3* r, cmsHPROFILE hProfile)
{
cmsCIEXYZ *PtrRed, *PtrGreen, *PtrBlue;
*** 341,351 ****
cmsTagTypeSignature OriginalType;
cmsTagSignature tag16;
cmsTagSignature tagFloat;
cmsContext ContextID = cmsGetProfileContextID(hProfile);
! // On named color, take the appropiate tag
if (cmsGetDeviceClass(hProfile) == cmsSigNamedColorClass) {
cmsPipeline* Lut;
cmsNAMEDCOLORLIST* nc = (cmsNAMEDCOLORLIST*) cmsReadTag(hProfile, cmsSigNamedColor2Tag);
--- 341,351 ----
cmsTagTypeSignature OriginalType;
cmsTagSignature tag16;
cmsTagSignature tagFloat;
cmsContext ContextID = cmsGetProfileContextID(hProfile);
! // On named color, take the appropriate tag
if (cmsGetDeviceClass(hProfile) == cmsSigNamedColorClass) {
cmsPipeline* Lut;
cmsNAMEDCOLORLIST* nc = (cmsNAMEDCOLORLIST*) cmsReadTag(hProfile, cmsSigNamedColor2Tag);
*** 363,375 ****
return NULL;
}
return Lut;
}
! // This is an attempt to reuse this funtion to retrieve the matrix-shaper as pipeline no
// matter other LUT are present and have precedence. Intent = -1 means just this.
! if (Intent != -1) {
tag16 = Device2PCS16[Intent];
tagFloat = Device2PCSFloat[Intent];
if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence
--- 363,375 ----
return NULL;
}
return Lut;
}
! // This is an attempt to reuse this function to retrieve the matrix-shaper as pipeline no
// matter other LUT are present and have precedence. Intent = -1 means just this.
! if (Intent >= INTENT_PERCEPTUAL && Intent <= INTENT_ABSOLUTE_COLORIMETRIC) {
tag16 = Device2PCS16[Intent];
tagFloat = Device2PCSFloat[Intent];
if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence
*** 421,431 ****
// Lut was not found, try to create a matrix-shaper
// Check if this is a grayscale profile.
if (cmsGetColorSpace(hProfile) == cmsSigGrayData) {
! // if so, build appropiate conversion tables.
// The tables are the PCS iluminant, scaled across GrayTRC
return BuildGrayInputMatrixPipeline(hProfile);
}
// Not gray, create a normal matrix-shaper
--- 421,431 ----
// Lut was not found, try to create a matrix-shaper
// Check if this is a grayscale profile.
if (cmsGetColorSpace(hProfile) == cmsSigGrayData) {
! // if so, build appropriate conversion tables.
// The tables are the PCS iluminant, scaled across GrayTRC
return BuildGrayInputMatrixPipeline(hProfile);
}
// Not gray, create a normal matrix-shaper
*** 576,586 ****
cmsColorSpaceSignature dataSpace = cmsGetColorSpace(hProfile);
if (Lut == NULL) return NULL;
// If PCS is Lab or XYZ, the floating point tag is accepting data in the space encoding,
! // and since the formatter has already accomodated to 0..1.0, we should undo this change
if ( PCS == cmsSigLabData)
{
if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToLabFloat(ContextID)))
goto Error;
}
--- 576,586 ----
cmsColorSpaceSignature dataSpace = cmsGetColorSpace(hProfile);
if (Lut == NULL) return NULL;
// If PCS is Lab or XYZ, the floating point tag is accepting data in the space encoding,
! // and since the formatter has already accommodated to 0..1.0, we should undo this change
if ( PCS == cmsSigLabData)
{
if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToLabFloat(ContextID)))
goto Error;
}
*** 617,627 ****
cmsTagSignature tag16;
cmsTagSignature tagFloat;
cmsContext ContextID = cmsGetProfileContextID(hProfile);
! if (Intent != -1) {
tag16 = PCS2Device16[Intent];
tagFloat = PCS2DeviceFloat[Intent];
if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence
--- 617,627 ----
cmsTagSignature tag16;
cmsTagSignature tagFloat;
cmsContext ContextID = cmsGetProfileContextID(hProfile);
! if (Intent >= INTENT_PERCEPTUAL && Intent <= INTENT_ABSOLUTE_COLORIMETRIC) {
tag16 = PCS2Device16[Intent];
tagFloat = PCS2DeviceFloat[Intent];
if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence
*** 678,688 ****
// Lut not found, try to create a matrix-shaper
// Check if this is a grayscale profile.
if (cmsGetColorSpace(hProfile) == cmsSigGrayData) {
! // if so, build appropiate conversion tables.
// The tables are the PCS iluminant, scaled across GrayTRC
return BuildGrayOutputPipeline(hProfile);
}
// Not gray, create a normal matrix-shaper, which only operates in XYZ space
--- 678,688 ----
// Lut not found, try to create a matrix-shaper
// Check if this is a grayscale profile.
if (cmsGetColorSpace(hProfile) == cmsSigGrayData) {
! // if so, build appropriate conversion tables.
// The tables are the PCS iluminant, scaled across GrayTRC
return BuildGrayOutputPipeline(hProfile);
}
// Not gray, create a normal matrix-shaper, which only operates in XYZ space
*** 736,754 ****
// tag name here may default to AToB0
cmsPipeline* _cmsReadDevicelinkLUT(cmsHPROFILE hProfile, int Intent)
{
cmsPipeline* Lut;
cmsTagTypeSignature OriginalType;
! cmsTagSignature tag16 = Device2PCS16[Intent];
! cmsTagSignature tagFloat = Device2PCSFloat[Intent];
cmsContext ContextID = cmsGetProfileContextID(hProfile);
! // On named color, take the appropiate tag
if (cmsGetDeviceClass(hProfile) == cmsSigNamedColorClass) {
! cmsNAMEDCOLORLIST* nc = (cmsNAMEDCOLORLIST*) cmsReadTag(hProfile, cmsSigNamedColor2Tag);
if (nc == NULL) return NULL;
Lut = cmsPipelineAlloc(ContextID, 0, 0);
if (Lut == NULL)
--- 736,760 ----
// tag name here may default to AToB0
cmsPipeline* _cmsReadDevicelinkLUT(cmsHPROFILE hProfile, int Intent)
{
cmsPipeline* Lut;
cmsTagTypeSignature OriginalType;
! cmsTagSignature tag16;
! cmsTagSignature tagFloat;
cmsContext ContextID = cmsGetProfileContextID(hProfile);
! if (Intent < INTENT_PERCEPTUAL || Intent > INTENT_ABSOLUTE_COLORIMETRIC)
! return NULL;
!
! tag16 = Device2PCS16[Intent];
! tagFloat = Device2PCSFloat[Intent];
!
! // On named color, take the appropriate tag
if (cmsGetDeviceClass(hProfile) == cmsSigNamedColorClass) {
! cmsNAMEDCOLORLIST* nc = (cmsNAMEDCOLORLIST*)cmsReadTag(hProfile, cmsSigNamedColor2Tag);
if (nc == NULL) return NULL;
Lut = cmsPipelineAlloc(ContextID, 0, 0);
if (Lut == NULL)
*** 760,785 ****
if (cmsGetColorSpace(hProfile) == cmsSigLabData)
if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID)))
goto Error;
return Lut;
! Error:
cmsPipelineFree(Lut);
cmsFreeNamedColorList(nc);
return NULL;
}
if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence
// Floating point LUT are always V
return _cmsReadFloatDevicelinkTag(hProfile, tagFloat);
}
tagFloat = Device2PCSFloat[0];
if (cmsIsTag(hProfile, tagFloat)) {
! return cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat));
}
if (!cmsIsTag(hProfile, tag16)) { // Is there any LUT-Based table?
tag16 = Device2PCS16[0];
--- 766,792 ----
if (cmsGetColorSpace(hProfile) == cmsSigLabData)
if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID)))
goto Error;
return Lut;
! Error:
cmsPipelineFree(Lut);
cmsFreeNamedColorList(nc);
return NULL;
}
+
if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence
// Floating point LUT are always V
return _cmsReadFloatDevicelinkTag(hProfile, tagFloat);
}
tagFloat = Device2PCSFloat[0];
if (cmsIsTag(hProfile, tagFloat)) {
! return cmsPipelineDup((cmsPipeline*)cmsReadTag(hProfile, tagFloat));
}
if (!cmsIsTag(hProfile, tag16)) { // Is there any LUT-Based table?
tag16 = Device2PCS16[0];
*** 787,797 ****
}
// Check profile version and LUT type. Do the necessary adjustments if needed
// Read the tag
! Lut = (cmsPipeline*) cmsReadTag(hProfile, tag16);
if (Lut == NULL) return NULL;
// The profile owns the Lut, so we need to copy it
Lut = cmsPipelineDup(Lut);
if (Lut == NULL) return NULL;
--- 794,804 ----
}
// Check profile version and LUT type. Do the necessary adjustments if needed
// Read the tag
! Lut = (cmsPipeline*)cmsReadTag(hProfile, tag16);
if (Lut == NULL) return NULL;
// The profile owns the Lut, so we need to copy it
Lut = cmsPipelineDup(Lut);
if (Lut == NULL) return NULL;
*** 808,823 ****
if (OriginalType != cmsSigLut16Type) return Lut;
// Here it is possible to get Lab on both sides
if (cmsGetColorSpace(hProfile) == cmsSigLabData) {
! if(!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageAllocLabV4ToV2(ContextID)))
goto Error2;
}
if (cmsGetPCS(hProfile) == cmsSigLabData) {
! if(!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID)))
goto Error2;
}
return Lut;
--- 815,830 ----
if (OriginalType != cmsSigLut16Type) return Lut;
// Here it is possible to get Lab on both sides
if (cmsGetColorSpace(hProfile) == cmsSigLabData) {
! if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageAllocLabV4ToV2(ContextID)))
goto Error2;
}
if (cmsGetPCS(hProfile) == cmsSigLabData) {
! if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID)))
goto Error2;
}
return Lut;
*** 948,958 ****
return TRUE;
}
! // Auxiliar, read and duplicate a MLU if found.
static
cmsMLU* GetMLUFromProfile(cmsHPROFILE h, cmsTagSignature sig)
{
cmsMLU* mlu = (cmsMLU*) cmsReadTag(h, sig);
if (mlu == NULL) return NULL;
--- 955,965 ----
return TRUE;
}
! // Auxiliary, read and duplicate a MLU if found.
static
cmsMLU* GetMLUFromProfile(cmsHPROFILE h, cmsTagSignature sig)
{
cmsMLU* mlu = (cmsMLU*) cmsReadTag(h, sig);
if (mlu == NULL) return NULL;
< prev index next >