Class PNMImageReader
- java.lang.Object
-
- javax.imageio.ImageReader
-
- com.github.jaiimageio.impl.plugins.pnm.PNMImageReader
-
public class PNMImageReader extends javax.imageio.ImageReader
This class is the Java Image IO plugin reader for PNM images. It may subsample the image, clip the image, select sub-bands, and shift the decoded image origin if the proper decoding parameter are set in the providedPNMImageReadParam
.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
aLine
private boolean
gotHeader
Indicates whether the header is read.private int
height
The original image height.private javax.imageio.stream.ImageInputStream
iis
The input stream where reads fromprivate long
imageDataOffset
The stream position where the image data starts.private static int
LINE_FEED
private static byte[]
lineSeparator
private int
maxValue
Maximum pixel value.private PNMMetadata
metadata
private static int
PBM_ASCII
private static int
PBM_RAW
private static int
PGM_ASCII
private static int
PGM_RAW
private static int
PPM_ASCII
private static int
PPM_RAW
private java.util.StringTokenizer
token
private int
variant
File variant: PBM/PGM/PPM, ASCII/RAW.private int
width
The original image width.
-
Constructor Summary
Constructors Constructor Description PNMImageReader(javax.imageio.spi.ImageReaderSpi originator)
ConstructsPNMImageReader
from the providedImageReaderSpi
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canReadRaster()
private void
checkIndex(int imageIndex)
javax.imageio.ImageReadParam
getDefaultReadParam()
int
getHeight(int imageIndex)
javax.imageio.metadata.IIOMetadata
getImageMetadata(int imageIndex)
java.util.Iterator
getImageTypes(int imageIndex)
int
getMaxValue()
int
getNumImages(boolean allowSearch)
Overrides the method defined in the superclass.javax.imageio.metadata.IIOMetadata
getStreamMetadata()
int
getVariant()
int
getWidth(int imageIndex)
boolean
isRandomAccessEasy(int imageIndex)
private boolean
isRaw(int v)
Returns true if file variant is raw format, false if ASCII.java.awt.image.BufferedImage
read(int imageIndex, javax.imageio.ImageReadParam param)
private void
readComments(javax.imageio.stream.ImageInputStream stream, PNMMetadata metadata)
Reads the comments.void
readHeader()
private int
readInteger(javax.imageio.stream.ImageInputStream stream)
Reads the next integer.java.awt.image.Raster
readRaster(int imageIndex, javax.imageio.ImageReadParam param)
void
reset()
void
setInput(java.lang.Object input, boolean seekForwardOnly, boolean ignoreMetadata)
Overrides the method defined in the superclass.private void
skipInteger(javax.imageio.stream.ImageInputStream stream, int num)
-
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, 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, setInput, setInput, setLocale
-
-
-
-
Field Detail
-
PBM_ASCII
private static final int PBM_ASCII
- See Also:
- Constant Field Values
-
PGM_ASCII
private static final int PGM_ASCII
- See Also:
- Constant Field Values
-
PPM_ASCII
private static final int PPM_ASCII
- See Also:
- Constant Field Values
-
PBM_RAW
private static final int PBM_RAW
- See Also:
- Constant Field Values
-
PGM_RAW
private static final int PGM_RAW
- See Also:
- Constant Field Values
-
PPM_RAW
private static final int PPM_RAW
- See Also:
- Constant Field Values
-
LINE_FEED
private static final int LINE_FEED
- See Also:
- Constant Field Values
-
lineSeparator
private static byte[] lineSeparator
-
variant
private int variant
File variant: PBM/PGM/PPM, ASCII/RAW.
-
maxValue
private int maxValue
Maximum pixel value.
-
iis
private javax.imageio.stream.ImageInputStream iis
The input stream where reads from
-
gotHeader
private boolean gotHeader
Indicates whether the header is read.
-
imageDataOffset
private long imageDataOffset
The stream position where the image data starts.
-
width
private int width
The original image width.
-
height
private int height
The original image height.
-
aLine
private java.lang.String aLine
-
token
private java.util.StringTokenizer token
-
metadata
private PNMMetadata metadata
-
-
Method Detail
-
setInput
public void setInput(java.lang.Object input, boolean seekForwardOnly, boolean ignoreMetadata)
Overrides the method defined in the superclass.- Overrides:
setInput
in classjavax.imageio.ImageReader
-
getNumImages
public int getNumImages(boolean allowSearch) throws java.io.IOException
Overrides the method defined in the superclass.- Specified by:
getNumImages
in classjavax.imageio.ImageReader
- Throws:
java.io.IOException
-
getWidth
public int getWidth(int imageIndex) throws java.io.IOException
- Specified by:
getWidth
in classjavax.imageio.ImageReader
- Throws:
java.io.IOException
-
getHeight
public int getHeight(int imageIndex) throws java.io.IOException
- Specified by:
getHeight
in classjavax.imageio.ImageReader
- Throws:
java.io.IOException
-
getVariant
public int getVariant()
-
getMaxValue
public int getMaxValue()
-
checkIndex
private void checkIndex(int imageIndex)
-
readHeader
public void readHeader() throws java.io.IOException
- Throws:
java.io.IOException
-
getImageTypes
public java.util.Iterator getImageTypes(int imageIndex) throws java.io.IOException
- Specified by:
getImageTypes
in classjavax.imageio.ImageReader
- Throws:
java.io.IOException
-
getDefaultReadParam
public javax.imageio.ImageReadParam getDefaultReadParam()
- Overrides:
getDefaultReadParam
in classjavax.imageio.ImageReader
-
getImageMetadata
public javax.imageio.metadata.IIOMetadata getImageMetadata(int imageIndex) throws java.io.IOException
- Specified by:
getImageMetadata
in classjavax.imageio.ImageReader
- Throws:
java.io.IOException
-
getStreamMetadata
public javax.imageio.metadata.IIOMetadata getStreamMetadata() throws java.io.IOException
- Specified by:
getStreamMetadata
in classjavax.imageio.ImageReader
- Throws:
java.io.IOException
-
isRandomAccessEasy
public boolean isRandomAccessEasy(int imageIndex) throws java.io.IOException
- Overrides:
isRandomAccessEasy
in classjavax.imageio.ImageReader
- Throws:
java.io.IOException
-
read
public java.awt.image.BufferedImage read(int imageIndex, javax.imageio.ImageReadParam param) throws java.io.IOException
- Specified by:
read
in classjavax.imageio.ImageReader
- Throws:
java.io.IOException
-
canReadRaster
public boolean canReadRaster()
- Overrides:
canReadRaster
in classjavax.imageio.ImageReader
-
readRaster
public java.awt.image.Raster readRaster(int imageIndex, javax.imageio.ImageReadParam param) throws java.io.IOException
- Overrides:
readRaster
in classjavax.imageio.ImageReader
- Throws:
java.io.IOException
-
reset
public void reset()
- Overrides:
reset
in classjavax.imageio.ImageReader
-
isRaw
private boolean isRaw(int v)
Returns true if file variant is raw format, false if ASCII.
-
readComments
private void readComments(javax.imageio.stream.ImageInputStream stream, PNMMetadata metadata) throws java.io.IOException
Reads the comments.- Throws:
java.io.IOException
-
readInteger
private int readInteger(javax.imageio.stream.ImageInputStream stream) throws java.io.IOException
Reads the next integer.- Throws:
java.io.IOException
-
skipInteger
private void skipInteger(javax.imageio.stream.ImageInputStream stream, int num) throws java.io.IOException
- Throws:
java.io.IOException
-
-