#4 isCWT: NPE reading ColorSpaceType for JPXDecode'd image

closed-fixed
Elfi Heck
None
5
2012-07-20
2012-07-11
Stefan
No

While rendering the attached Example.pdf an NPE is thrown and no image is generated.

Product

intarsys cwt v5.5 Build 20120626-1105
(with packaged jai_imageio.jar)
JRE 1.6.0_33

Exception

Caused by: java.lang.NullPointerException
at de.intarsys.cwt.image.ImageTools.extractJPEGColorSpaceType(ImageTools.java:73)
at de.intarsys.cwt.image.ImageTools.extractJPEGColorSpaceType(ImageTools.java:100)
at de.intarsys.pdf.platform.cwt.image.awt.ImageConverterPdf2Awt.createRasterFromJPEG(ImageConverterPdf2Awt.java:285)
at de.intarsys.pdf.platform.cwt.image.awt.ImageConverterPdf2Awt.createRaster(ImageConverterPdf2Awt.java:173)
at de.intarsys.pdf.platform.cwt.image.awt.ImageConverterPdf2Awt.createBufferedImage(ImageConverterPdf2Awt.java:83)
... 28 more

Cause

ImageTools.extractJPEGColorSpaceType does not check allegedColorNode for null.

(Quick) Fix

Throw an ImageException if allegedColorNode is null.

isCWT/src/de/intarsys/cwt/image/ImageTools.java from line 70:

allegedChromaNode = allegedChromaNode.getNextSibling();
}
allegedColorNode = allegedChromaNode.getFirstChild();
+ if (allegedColorNode == null) {
+ throw new ImageException("color space not declared (ColorSpaceType missing)"); //$NON-NLS-1$
+ }
while (!allegedColorNode.getLocalName().equals("ColorSpaceType")) { //$NON-NLS-1$
allegedColorNode = allegedColorNode.getNextSibling();
}

.. the resulting image is not really perfect, but some output was generated.

Regards Stefan.

Discussion

  • Stefan
    Stefan
    2012-07-11

    PDF with JBIG2/JPX

     
    Attachments
  • Stefan
    Stefan
    2012-07-11

    • assigned_to: nobody --> mtraut
     
  • Elfi Heck
    Elfi Heck
    2012-07-18

    • assigned_to: mtraut --> eheck
     
  • Elfi Heck
    Elfi Heck
    2012-07-20

    Fixed for next release. I've added a few additional null checks.
    That you are still seeing a garbled picture seems to be because of a problem with an SMask, BTW. I will have a look.
    Thanks for the test document.

     
  • Elfi Heck
    Elfi Heck
    2012-07-20

    • status: open --> closed-fixed
     
  • Elfi Heck
    Elfi Heck
    2012-07-20

    About that SMask: To display the document correctly you can remove the code checking for MAX_SCALE in ImageConverterPdf2Awt. But rendering will become incredibly sloooow. (That's why I put that code there in the first place)