LOG.error( "Can't find an ImageIO plugin to decode the JBIG2 encoded datastream.");
return;
}
ImageReader reader = readers.next();
COSDictionary decodeP = (COSDictionary) options.getDictionaryObject(COSName.DECODE_PARMS);
COSInteger bits = (COSInteger) options.getDictionaryObject(COSName.BITS_PER_COMPONENT);
COSStream st = null;
if (decodeP != null)
{
st = (COSStream) decodeP.getDictionaryObject(COSName.JBIG2_GLOBALS);
}
if(st != null)
{
reader.setInput(ImageIO.createImageInputStream(new SequenceInputStream(st.getFilteredStream(),compressedData)));
}
else
{
reader.setInput(ImageIO.createImageInputStream(compressedData));
}
BufferedImage bi = reader.read(0);
reader.dispose();
if ( bi != null )
{
// I am assuming since JBIG2 is always black and white
// depending on your renderer this might or might be needed
if(bi.getColorModel().getPixelSize() != bits.intValue())
{
if(bits.intValue() != 1)
{
LOG.error("Do not know how to deal with JBIG2 with more than 1 bit");
return;
}
BufferedImage packedImage =