< prev index next >

src/java.desktop/share/native/liblcms/cmscnvrt.c

Print this page
@@ -261,11 +261,11 @@
      return TempK;
  }
  
  // Compute a CHAD based on a given temperature
  static
-     void Temp2CHAD(cmsMAT3* Chad, cmsFloat64Number Temp)
+ void Temp2CHAD(cmsMAT3* Chad, cmsFloat64Number Temp)
  {
      cmsCIEXYZ White;
      cmsCIExyY ChromaticityOfWhite;
  
      cmsWhitePointFromTemp(&ChromaticityOfWhite, Temp);

@@ -742,10 +742,20 @@
      // Keep normal transform for other colors
      bp ->cmyk2cmyk ->Eval16Fn(In, Out, bp ->cmyk2cmyk->Data);
      return TRUE;
  }
  
+ 
+ // Check whatever the profile is a CMYK->CMYK devicelink
+ static
+ cmsBool is_cmyk_devicelink(cmsHPROFILE hProfile)
+ {
+     return cmsGetDeviceClass(hProfile) == cmsSigLinkClass &&
+             cmsGetColorSpace(hProfile) == cmsSigCmykData &&
+             cmsGetColorSpace(hProfile) == cmsSigCmykData;
+ }
+ 
  // This is the entry for black-preserving K-only intents, which are non-ICC
  static
  cmsPipeline*  BlackPreservingKOnlyIntents(cmsContext     ContextID,
                                            cmsUInt32Number nProfiles,
                                            cmsUInt32Number TheIntents[],

@@ -774,18 +784,20 @@
  
      // Trim all CMYK devicelinks at the end
      lastProfilePos = nProfiles - 1;
      hLastProfile = hProfiles[lastProfilePos];
  
-     while (lastProfilePos > 1)
+     // Skip CMYK->CMYK devicelinks on ending
+     while (is_cmyk_devicelink(hLastProfile))
      {
-         hLastProfile = hProfiles[--lastProfilePos];
-         if (cmsGetColorSpace(hLastProfile) != cmsSigCmykData ||
-             cmsGetDeviceClass(hLastProfile) != cmsSigLinkClass)
+         if (lastProfilePos < 2)
              break;
+ 
+         hLastProfile = hProfiles[--lastProfilePos];
      }
  
+ 
      preservationProfilesCount = lastProfilePos + 1;
  
      // Check for non-cmyk profiles
      if (cmsGetColorSpace(hProfiles[0]) != cmsSigCmykData ||
          !(cmsGetColorSpace(hLastProfile) == cmsSigCmykData ||

@@ -798,11 +810,11 @@
  
      memset(&bp, 0, sizeof(bp));
  
      // Create a LUT holding normal ICC transform
      bp.cmyk2cmyk = DefaultICCintents(ContextID,
-                                      preservationProfilesCount,
+         preservationProfilesCount,
          ICCIntents,
          hProfiles,
          BPC,
          AdaptationStates,
          dwFlags);

@@ -810,11 +822,11 @@
      if (bp.cmyk2cmyk == NULL) goto Error;
  
      // Now, compute the tone curve
      bp.KTone = _cmsBuildKToneCurve(ContextID,
          4096,
-                                     preservationProfilesCount,
+         preservationProfilesCount,
          ICCIntents,
          hProfiles,
          BPC,
          AdaptationStates,
          dwFlags);

@@ -1000,16 +1012,17 @@
  
      // Trim all CMYK devicelinks at the end
      lastProfilePos = nProfiles - 1;
      hLastProfile = hProfiles[lastProfilePos];
  
-     while (lastProfilePos > 1)
+     // Skip CMYK->CMYK devicelinks on ending
+     while (is_cmyk_devicelink(hLastProfile))
      {
-         hLastProfile = hProfiles[--lastProfilePos];
-         if (cmsGetColorSpace(hLastProfile) != cmsSigCmykData ||
-             cmsGetDeviceClass(hLastProfile) != cmsSigLinkClass)
+         if (lastProfilePos < 2)
              break;
+ 
+         hLastProfile = hProfiles[--lastProfilePos];
      }
  
      preservationProfilesCount = lastProfilePos + 1;
  
      // Check for non-cmyk profiles

@@ -1175,12 +1188,11 @@
  {
      _cmsIntentsPluginChunkType* ctx = ( _cmsIntentsPluginChunkType*) _cmsContextGetClientChunk(ContextID, IntentPlugin);
      cmsIntentsList* pt;
      cmsUInt32Number nIntents;
  
- 
-     for (nIntents=0, pt = ctx->Intents; pt != NULL; pt = pt -> Next)
+     for (nIntents=0, pt = DefaultIntents; pt != NULL; pt = pt -> Next)
      {
          if (nIntents < nMax) {
              if (Codes != NULL)
                  Codes[nIntents] = pt ->Intent;
  

@@ -1189,11 +1201,11 @@
          }
  
          nIntents++;
      }
  
-     for (nIntents=0, pt = DefaultIntents; pt != NULL; pt = pt -> Next)
+     for (pt = ctx->Intents; pt != NULL; pt = pt -> Next)
      {
          if (nIntents < nMax) {
              if (Codes != NULL)
                  Codes[nIntents] = pt ->Intent;
  

@@ -1201,10 +1213,11 @@
                  Descriptions[nIntents] = pt ->Description;
          }
  
          nIntents++;
      }
+ 
      return nIntents;
  }
  
  cmsUInt32Number CMSEXPORT cmsGetSupportedIntents(cmsUInt32Number nMax, cmsUInt32Number* Codes, char** Descriptions)
  {
< prev index next >