@Override
public final DecodeResult decode(InputStream encoded, OutputStream decoded,
COSDictionary parameters, int index) throws IOException
{
ImageReader reader = findImageReader("JBIG2", "jbig2-imageio is not installed");
DecodeResult result = new DecodeResult(new COSDictionary());
result.getParameters().addAll(parameters);
COSInteger bits = (COSInteger) parameters.getDictionaryObject(COSName.BITS_PER_COMPONENT);
COSDictionary params = (COSDictionary) parameters.getDictionaryObject(COSName.DECODE_PARMS);
COSStream globals = null;
if (params != null)
{
globals = (COSStream) params.getDictionaryObject(COSName.JBIG2_GLOBALS);
}
ImageInputStream iis = null;
try
{