Package org.apache.pdfbox.jbig2
Class JBIG2ImageReader
- java.lang.Object
-
- javax.imageio.ImageReader
-
- org.apache.pdfbox.jbig2.JBIG2ImageReader
-
public class JBIG2ImageReader extends javax.imageio.ImageReader- See Also:
ImageReader
-
-
Field Summary
Fields Modifier and Type Field Description private JBIG2DocumentdocumentJBIG2 document to which we delegate current work.private JBIG2GlobalsglobalsGlobals are JBIG2 segments for PDF wide use.
-
Constructor Summary
Constructors Constructor Description JBIG2ImageReader(javax.imageio.spi.ImageReaderSpi originatingProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanReadRaster()JBIG2ReadParamgetDefaultReadParam()private JBIG2ReadParamgetDefaultReadParam(int imageIndex)Returns a default ImageReadParam object for a specific page.private JBIG2DocumentgetDocument()JBIG2GlobalsgetGlobals()Returns decoded segments that has been set as globals.intgetHeight(int imageIndex)Calculates the height of the specified page.javax.imageio.metadata.IIOMetadatagetImageMetadata(int imageIndex)Simply returns theJBIG2ImageMetadata.java.util.Iterator<javax.imageio.ImageTypeSpecifier>getImageTypes(int imageIndex)Returns the iterator for available image types.intgetNumImages(boolean allowSearch)private JBIG2PagegetPage(int imageIndex)javax.imageio.metadata.IIOMetadatagetStreamMetadata()This ImageIO plugin doesn't recordIIOMetadata.intgetWidth(int imageIndex)Calculates the width of the specified page.JBIG2GlobalsprocessGlobals(javax.imageio.stream.ImageInputStream globalsInputStream)Decodes and returns the global segments.java.awt.image.BufferedImageread(int imageIndex, javax.imageio.ImageReadParam param)Returns the decoded image of specified page considering the givenJBIG2ReadParams.java.awt.image.RasterreadRaster(int imageIndex, javax.imageio.ImageReadParam param)voidsetGlobals(JBIG2Globals globals)Simply sets the globals.voidsetInput(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
-
-
-
-
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- - TheImageReaderSpithat is invoking this constructor, ornull.- Throws:
java.io.IOException- if something went wrong while reading the provided stream.- See Also:
ImageReader(ImageReaderSpi)
-
-
Method Detail
-
getDefaultReadParam
public JBIG2ReadParam getDefaultReadParam()
- Overrides:
getDefaultReadParamin classjavax.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.IOExceptionCalculates the width of the specified page.- Specified by:
getWidthin classjavax.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.IOExceptionCalculates the height of the specified page.- Specified by:
getHeightin classjavax.imageio.ImageReader- Parameters:
imageIndex- - The image index. In this case it is the page number.- Returns:
- The height of the specified page or
0if 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.IOExceptionSimply returns theJBIG2ImageMetadata.- Specified by:
getImageMetadatain classjavax.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.IOExceptionReturns the iterator for available image types.- Specified by:
getImageTypesin classjavax.imageio.ImageReader- Parameters:
imageIndex- - The page number.- Returns:
- An
Iteratorfor 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:
getNumImagesin classjavax.imageio.ImageReader- Throws:
java.io.IOException- See Also:
ImageReader.getNumImages(boolean)
-
getStreamMetadata
public javax.imageio.metadata.IIOMetadata getStreamMetadata()
This ImageIO plugin doesn't recordIIOMetadata.- Specified by:
getStreamMetadatain classjavax.imageio.ImageReader- Returns:
nullat 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.IOExceptionReturns the decoded image of specified page considering the givenJBIG2ReadParams.- Specified by:
readin classjavax.imageio.ImageReader- Throws:
java.io.IOException- See Also:
ImageReader.read(int, ImageReadParam)
-
canReadRaster
public boolean canReadRaster()
- Overrides:
canReadRasterin classjavax.imageio.ImageReader
-
readRaster
public java.awt.image.Raster readRaster(int imageIndex, javax.imageio.ImageReadParam param) throws java.io.IOException- Overrides:
readRasterin classjavax.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:
setInputin classjavax.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
-
-