Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6868109

CMYK image support in 1.6.x fails when it works in 1.5.x

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6u14
    • client-libs
    • 2d
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      any version of 1.5 works with the CMYK.pf and any version of 1.6 does not.
      The converse is not true. 1.5 works well wiht the CMYK.pf solution but works very slowly with the other solution.

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP

      A DESCRIPTION OF THE PROBLEM :
      I have a program which works in 1.5 and fails in 1.6. It relates to the support of CMYK images and ICC_Profiles. I have had to add the following code: (which sucks!)

      ColorSpace cmykColorSpace;

               if (TpInfo.jvmString.compareTo("1.6") < 0) {
                  InputStream is = tptiff.TIFFResources.class.getResourceAsStream("CMYK.pf");
                  ICC_Profile outputProfile = ICC_Profile.getInstance(is);
                  cmykColorSpace = new ICC_ColorSpace(outputProfile);
                  }
               else {
                  // ImageIO uses com.sun.media.jai.util.SimpleCMYKColorSpace when it reads
                  // untagged CMYK files. This require JAI, not good!
                  //final ColorSpace cmykColorSpace = SimpleCMYKColorSpace.getInstance();
                  //final ColorSpace cmykColorSpace = ColorSpace.getInstance(ColorSpace.TYPE_CMYK);

                  // this uses a simple extended colorspace
                  cmykColorSpace = new CMYKColorSpace();
                  }

               ComponentColorModel colorModel = new ComponentColorModel(cmykColorSpace,
                                                                       new int[] { 8, 8, 8, 8 },
                                                                       false,
                                                                       false,
                                                                       Transparency.OPAQUE,
                                                                       DataBuffer.TYPE_BYTE);

               WritableRaster raster = colorModel.createCompatibleWritableRaster(tkn.hs,tkn.vs);
               BufferedImage bImg = new BufferedImage(colorModel,raster,false,null);
               WritableRaster rst = bImg.getRaster();
               int bl = tkn.hs*tkn.vs;
               byte[] b = tkn.iData;
               rst.setDataElements(0,0,tkn.hs,tkn.vs,b);
               double xs = pageUnits()/tkn.hr;
               double ys = pageUnits()/tkn.vr;
               g.scale(xs,ys);
               AffineTransform atr = new AffineTransform();
               atr.setToIdentity();
               g.drawImage(bImg,atr,this);

      The CMYK.pf file is the file found in the older version of JAI. It is not acceptable to require JAI to get CMYK to work!

      Clearly you broke something when you went to 1.6

      REPRODUCIBILITY :
      This bug can be reproduced always.

            serb Sergey Bylokhov
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: