예제 #1
0
파일: Debug.java 프로젝트: srnsw/xena
 public static void debug(String message, ICC_Profile value) {
   debug("ICC_Profile " + message + ": " + ((value == null) ? "null" : value.toString()));
   if (value != null) {
     debug("\t getProfileClass: " + byteQuadToString(value.getProfileClass()));
     debug("\t getPCSType: " + byteQuadToString(value.getPCSType()));
     debug("\t getColorSpaceType() : " + byteQuadToString(value.getColorSpaceType()));
   }
 }
예제 #2
0
  /**
   * Creates an ICC color space from the given ICC color profile.
   *
   * <p>For standard Java color spaces, the built-in instance is returned. Otherwise, color spaces
   * are looked up from cache and created on demand.
   *
   * @param profile the ICC color profile. May not be {@code null}.
   * @return an ICC color space
   * @throws IllegalArgumentException if {@code profile} is {@code null}
   */
  public static ICC_ColorSpace createColorSpace(final ICC_Profile profile) {
    Validate.notNull(profile, "profile");

    byte[] profileHeader = profile.getData(ICC_Profile.icSigHead);

    ICC_ColorSpace cs = getInternalCS(profile.getColorSpaceType(), profileHeader);
    if (cs != null) {
      return cs;
    }

    // Special case for color profiles with rendering intent != 0, see isOffendingColorProfile
    // method
    // NOTE: Rendering intent is really a 4 byte value, but legal values are 0-3
    // (ICC1v42_2006_05_1.pdf, 7.2.15, p. 19)
    if (profileHeader[ICC_Profile.icHdrRenderingIntent] != 0) {
      profileHeader[ICC_Profile.icHdrRenderingIntent] = 0;

      // Test again if this is an internal CS
      cs = getInternalCS(profile.getColorSpaceType(), profileHeader);
      if (cs != null) {
        return cs;
      }

      // NOTE: The intent change breaks JDK7: Seems to be a bug in ICC_Profile.getData/setData,
      // as calling it with unchanged header data, still breaks when creating new ICC_ColorSpace...
      // However, we simply skip that, as JDK7 handles the rendering intents already.
      if (!JDK_HANDLES_RENDERING_INTENTS) {
        // Fix profile before lookup/create
        profile.setData(ICC_Profile.icSigHead, profileHeader);
      }
    }

    // Special handling to detect problematic Corbis RGB ICC Profile.
    // This makes sure tags that are expected to be of type 'XYZ ' really have this expected type.
    // Should leave other ICC profiles unchanged.
    if (fixProfileXYZTag(profile, ICC_Profile.icSigMediaWhitePointTag)) {
      fixProfileXYZTag(profile, ICC_Profile.icSigRedColorantTag);
      fixProfileXYZTag(profile, ICC_Profile.icSigGreenColorantTag);
      fixProfileXYZTag(profile, ICC_Profile.icSigBlueColorantTag);
    }

    return getCachedOrCreateCS(profile, profileHeader);
  }
예제 #3
0
파일: Debug.java 프로젝트: srnsw/xena
  public static String getDebug(String message, ICC_Profile value) {

    StringBuffer result = new StringBuffer();

    result.append(
        getDebug("ICC_Profile " + message + ": " + ((value == null) ? "null" : value.toString()))
            + newline);
    if (value != null) {
      result.append(
          getDebug("\t getProfileClass: " + byteQuadToString(value.getProfileClass())) + newline);
      result.append(getDebug("\t getPCSType: " + byteQuadToString(value.getPCSType())) + newline);
      result.append(
          getDebug("\t getColorSpaceType() : " + byteQuadToString(value.getColorSpaceType()))
              + newline);
    }

    return result.toString();
  }
예제 #4
0
  /**
   * Tests whether an ICC color profile is equal to the default sRGB profile.
   *
   * @param profile the ICC profile to test. May not be {@code null}.
   * @return {@code true} if {@code profile} is equal to the default sRGB profile.
   * @throws IllegalArgumentException if {@code profile} is {@code null}
   * @see java.awt.color.ColorSpace#isCS_sRGB()
   */
  public static boolean isCS_sRGB(final ICC_Profile profile) {
    Validate.notNull(profile, "profile");

    return profile.getColorSpaceType() == ColorSpace.TYPE_RGB
        && Arrays.equals(profile.getData(ICC_Profile.icSigHead), sRGB.header);
  }