BufferedImage processImage(GenericColorSpace decodeColorData,final ImageData imageData,final boolean imageMask,final PdfObject XObject) throws PdfException {
  cache.put(PdfObjectCache.ColorspacesUsed,decodeColorData.getID(),"x");
  imageData.getFilter(XObject);
  BufferedImage image=null;
  if (customImageHandler instanceof ImageDataHandler) {
    image=customImageHandler.processImageData(gs,XObject);
  }
 else   if (imageData.isJPX()) {
    removeJPXEncodingFromImageData(imageData,XObject);
  }
 else   if (imageData.isDCT()) {
    int adobeColorTransform=1;
    PdfObject decodeParms=XObject.getDictionary(PdfDictionary.DecodeParms);
    if (decodeParms != null) {
      adobeColorTransform=decodeParms.getInt(PdfDictionary.ColorTransform);
    }
    byte[] objectData;
    try {
      objectData=JPEGDecoder.getUnconvertedBytesFromJPEG(imageData.getObjectData(),adobeColorTransform);
      if (objectData == null) {
        objectData=JPEGDecoder.getBytesFromJPEGWithImageIO(imageData.getObjectData(),decodeColorData,XObject);
        decodeColorData=new DeviceRGBColorSpace();
        imageData.setCompCount(3);
        imageData.setDecodeArray(null);
      }
    }
 catch (    Exception e) {
      LogWriter.writeLog("[PDF] Exception " + e + " Processing JPEG data in ImageDecoder");
      objectData=JPEGDecoder.getBytesFromJPEGWithImageIO(imageData.getObjectData(),decodeColorData,XObject);
      decodeColorData=new DeviceRGBColorSpace();
      imageData.setCompCount(3);
      imageData.setDecodeArray(null);
    }
    XObject.setMixedArray(PdfDictionary.Filter,null);
    XObject.setDecodedStream(objectData);
    imageData.setObjectData(objectData);
    imageData.setDCT(false);
    imageData.setDepth(8);
    imageData.wasDCT(true);
  }
  if (image != null) {
    return image;
  }
 else {
    return convertDataToImage(imageMask,imageData,XObject,decodeColorData);
  }
}

BufferedImage processImage ( GenericColorSpace decodeColorData , final ImageData imageData , final boolean imageMask , final PdfObject XObject ) throws PdfException { cache . put ( PdfObjectCache . ColorspacesUsed , decodeColorData . getID ( ) , "x" ) ; imageData . getFilter ( XObject ) ; BufferedImage image = null ; if ( customImageHandler instanceof ImageDataHandler ) { image = customImageHandler . processImageData ( gs , XObject ) ; } else if ( imageData . isJPX ( ) ) { removeJPXEncodingFromImageData ( imageData , XObject ) ; } else if ( imageData . isDCT ( ) ) { int adobeColorTransform = 1 ; PdfObject decodeParms = XObject . getDictionary ( PdfDictionary . DecodeParms ) ; if ( decodeParms != null ) { adobeColorTransform = decodeParms . getInt ( PdfDictionary . ColorTransform ) ; } byte [ ] objectData ; try { objectData = JPEGDecoder . getUnconvertedBytesFromJPEG ( imageData . getObjectData ( ) , adobeColorTransform ) ; if ( objectData == null ) { objectData = JPEGDecoder . getBytesFromJPEGWithImageIO ( imageData . getObjectData ( ) , decodeColorData , XObject ) ; decodeColorData = new DeviceRGBColorSpace ( ) ; imageData . setCompCount ( 3 ) ; imageData . setDecodeArray ( null ) ; } } catch ( Exception e ) { LogWriter . writeLog ( "[PDF] Exception " + e + " Processing JPEG data in ImageDecoder" ) ; objectData = JPEGDecoder . getBytesFromJPEGWithImageIO ( imageData . getObjectData ( ) , decodeColorData , XObject ) ; decodeColorData = new DeviceRGBColorSpace ( ) ; imageData . setCompCount ( 3 ) ; imageData . setDecodeArray ( null ) ; } XObject . setMixedArray ( PdfDictionary . Filter , null ) ; XObject . setDecodedStream ( objectData ) ; imageData . setObjectData ( objectData ) ; imageData . setDCT ( false ) ; imageData . setDepth ( 8 ) ; imageData . wasDCT ( true ) ; } if ( image != null ) { return image ; } else { return convertDataToImage ( imageMask , imageData , XObject , decodeColorData ) ; } }
read in the image and process and save raw image
