예제 #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
  private ICC_Profile buildICCProfile(
      final ImageInfo info, final ColorSpace colorSpace, final ByteArrayOutputStream iccStream)
      throws IOException {
    if (iccStream != null && iccStream.size() > 0) {
      if (log.isDebugEnabled()) {
        log.debug("Effective ICC profile size: " + iccStream.size());
      }
      final int alignment = 4;
      final int padding = (alignment - iccStream.size() % alignment) % alignment;
      if (padding != 0) {
        try {
          iccStream.write(new byte[padding]);
        } catch (final IOException ioe) {
          throw new IOException("Error while aligning ICC stream: " + ioe.getMessage());
        }
      }

      ICC_Profile iccProfile = null;
      try {
        iccProfile = ColorProfileUtil.getICC_Profile(iccStream.toByteArray());
        if (log.isDebugEnabled()) {
          log.debug("JPEG has an ICC profile: " + iccProfile.toString());
        }
      } catch (final IllegalArgumentException iae) {
        log.warn(
            "An ICC profile is present in the JPEG file but it is invalid ("
                + iae.getMessage()
                + "). The color profile will be ignored. ("
                + info.getOriginalURI()
                + ")");
        return null;
      }
      if (iccProfile.getNumComponents() != colorSpace.getNumComponents()) {
        log.warn(
            "The number of components of the ICC profile ("
                + iccProfile.getNumComponents()
                + ") doesn't match the image ("
                + colorSpace.getNumComponents()
                + "). Ignoring the ICC color profile.");
        return null;
      } else {
        return iccProfile;
      }
    } else {
      return null; // no ICC profile available
    }
  }
예제 #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();
  }