Class JBIG2ImageReader


  • public class JBIG2ImageReader
    extends javax.imageio.ImageReader
    See Also:
    ImageReader
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private JBIG2Document document
      JBIG2 document to which we delegate current work.
      private JBIG2Globals globals
      Globals are JBIG2 segments for PDF wide use.
      • Fields inherited from class javax.imageio.ImageReader

        availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales
    • Constructor Summary

      Constructors 
      Constructor Description
      JBIG2ImageReader​(javax.imageio.spi.ImageReaderSpi originatingProvider)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canReadRaster()  
      JBIG2ReadParam getDefaultReadParam()  
      private JBIG2ReadParam getDefaultReadParam​(int imageIndex)
      Returns a default ImageReadParam object for a specific page.
      private JBIG2Document getDocument()  
      JBIG2Globals getGlobals()
      Returns decoded segments that has been set as globals.
      int getHeight​(int imageIndex)
      Calculates the height of the specified page.
      javax.imageio.metadata.IIOMetadata getImageMetadata​(int imageIndex)
      Simply returns the JBIG2ImageMetadata.
      java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypes​(int imageIndex)
      Returns the iterator for available image types.
      int getNumImages​(boolean allowSearch)  
      private JBIG2Page getPage​(int imageIndex)  
      javax.imageio.metadata.IIOMetadata getStreamMetadata()
      This ImageIO plugin doesn't record IIOMetadata.
      int getWidth​(int imageIndex)
      Calculates the width of the specified page.
      JBIG2Globals processGlobals​(javax.imageio.stream.ImageInputStream globalsInputStream)
      Decodes and returns the global segments.
      java.awt.image.BufferedImage read​(int imageIndex, javax.imageio.ImageReadParam param)
      Returns the decoded image of specified page considering the given JBIG2ReadParams.
      java.awt.image.Raster readRaster​(int imageIndex, javax.imageio.ImageReadParam param)  
      void setGlobals​(JBIG2Globals globals)
      Simply sets the globals.
      void setInput​(java.lang.Object input, boolean seekForwardOnly, boolean ignoreMetadata)  
      • Methods inherited from class javax.imageio.ImageReader

        abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, checkReadParamBandSettings, clearAbortRequest, computeRegions, dispose, getAspectRatio, getAvailableLocales, getDestination, getFormatName, getImageMetadata, getInput, getLocale, getMinIndex, getNumThumbnails, getOriginatingProvider, getRawImageType, getSourceRegion, getStreamMetadata, getThumbnailHeight, getThumbnailWidth, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, hasThumbnails, isIgnoringMetadata, isImageTiled, isRandomAccessEasy, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, read, readAll, readAll, readAsRenderedImage, readerSupportsThumbnails, readThumbnail, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, reset, setInput, setInput, setLocale
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • document

        private JBIG2Document document
        JBIG2 document to which we delegate current work.
      • globals

        private JBIG2Globals globals
        Globals are JBIG2 segments for PDF wide use.
    • Constructor Detail

      • JBIG2ImageReader

        public JBIG2ImageReader​(javax.imageio.spi.ImageReaderSpi originatingProvider)
                         throws java.io.IOException
        Parameters:
        originatingProvider - - The ImageReaderSpi that is invoking this constructor, or null.
        Throws:
        java.io.IOException - if something went wrong while reading the provided stream.
        See Also:
        ImageReader(ImageReaderSpi)
    • Method Detail

      • getDefaultReadParam

        public JBIG2ReadParam getDefaultReadParam()
        Overrides:
        getDefaultReadParam in class javax.imageio.ImageReader
        See Also:
        ImageReader.getDefaultReadParam()
      • getDefaultReadParam

        private JBIG2ReadParam getDefaultReadParam​(int imageIndex)
        Returns a default ImageReadParam object for a specific page.
        Parameters:
        imageIndex - - The page number.
        Returns:
      • getWidth

        public int getWidth​(int imageIndex)
                     throws java.io.IOException
        Calculates the width of the specified page.
        Specified by:
        getWidth in class javax.imageio.ImageReader
        Parameters:
        imageIndex - - The image index. In this case it is the page number.
        Returns:
        The width of the specified page.
        Throws:
        java.io.IOException - if an error occurs reading the width information from the input source.
      • getHeight

        public int getHeight​(int imageIndex)
                      throws java.io.IOException
        Calculates the height of the specified page.
        Specified by:
        getHeight in class javax.imageio.ImageReader
        Parameters:
        imageIndex - - The image index. In this case it is the page number.
        Returns:
        The height of the specified page or 0 if an error occurred.
        Throws:
        java.io.IOException - if an error occurs reading the height information from the input source.
      • getImageMetadata

        public javax.imageio.metadata.IIOMetadata getImageMetadata​(int imageIndex)
                                                            throws java.io.IOException
        Simply returns the JBIG2ImageMetadata.
        Specified by:
        getImageMetadata in class javax.imageio.ImageReader
        Returns:
        The associated JBIG2ImageMetadata.
        Throws:
        java.io.IOException - if an error occurs reading the height information from the input source.
      • getImageTypes

        public java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypes​(int imageIndex)
                                                                           throws java.io.IOException
        Returns the iterator for available image types.
        Specified by:
        getImageTypes in class javax.imageio.ImageReader
        Parameters:
        imageIndex - - The page number.
        Returns:
        An Iterator for available image types.
        Throws:
        java.io.IOException - if an error occurs reading the height information from the input source.
      • getNumImages

        public int getNumImages​(boolean allowSearch)
                         throws java.io.IOException
        Specified by:
        getNumImages in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
        See Also:
        ImageReader.getNumImages(boolean)
      • getStreamMetadata

        public javax.imageio.metadata.IIOMetadata getStreamMetadata()
        This ImageIO plugin doesn't record IIOMetadata.
        Specified by:
        getStreamMetadata in class javax.imageio.ImageReader
        Returns:
        null at every call.
      • getGlobals

        public JBIG2Globals getGlobals()
                                throws java.io.IOException
        Returns decoded segments that has been set as globals. Globals are jbig2 segments that are used in embedded case for file wide access. They are not assigned to a specific page.
        Returns:
        Decoded global segments.
        Throws:
        java.io.IOException - if an error occurs reading the height information from the input source.
      • read

        public java.awt.image.BufferedImage read​(int imageIndex,
                                                 javax.imageio.ImageReadParam param)
                                          throws java.io.IOException
        Returns the decoded image of specified page considering the given JBIG2ReadParams.
        Specified by:
        read in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
        See Also:
        ImageReader.read(int, ImageReadParam)
      • canReadRaster

        public boolean canReadRaster()
        Overrides:
        canReadRaster in class javax.imageio.ImageReader
      • readRaster

        public java.awt.image.Raster readRaster​(int imageIndex,
                                                javax.imageio.ImageReadParam param)
                                         throws java.io.IOException
        Overrides:
        readRaster in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • processGlobals

        public JBIG2Globals processGlobals​(javax.imageio.stream.ImageInputStream globalsInputStream)
                                    throws java.io.IOException
        Decodes and returns the global segments.
        Parameters:
        globalsInputStream - - The input stream of globals data.
        Returns:
        The decoded JBIG2Globals.
        Throws:
        java.io.IOException - if an error occurs reading the height information from the input source.
      • setGlobals

        public void setGlobals​(JBIG2Globals globals)
                        throws java.io.IOException
        Simply sets the globals.
        Parameters:
        globals - - The globals to set.
        Throws:
        java.io.IOException - if an error occurs
      • setInput

        public void setInput​(java.lang.Object input,
                             boolean seekForwardOnly,
                             boolean ignoreMetadata)
        Overrides:
        setInput in class javax.imageio.ImageReader
        See Also:
        ImageReader.setInput(Object, boolean, boolean)
      • getDocument

        private JBIG2Document getDocument()
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • getPage

        private JBIG2Page getPage​(int imageIndex)
                           throws java.io.IOException
        Throws:
        java.io.IOException