Class PNMImageReader
java.lang.Object
javax.imageio.ImageReader
com.github.jaiimageio.impl.plugins.pnm.PNMImageReader
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 provided
PNMImageReadParam
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
private boolean
Indicates whether the header is read.private int
The original image height.private ImageInputStream
The input stream where reads fromprivate long
The stream position where the image data starts.private static final int
private static byte[]
private int
Maximum pixel value.private PNMMetadata
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private StringTokenizer
private int
File variant: PBM/PGM/PPM, ASCII/RAW.private int
The original image width.Fields inherited from class javax.imageio.ImageReader
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales
-
Constructor Summary
ConstructorsConstructorDescriptionPNMImageReader
(ImageReaderSpi originator) ConstructsPNMImageReader
from the providedImageReaderSpi
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
private void
checkIndex
(int imageIndex) int
getHeight
(int imageIndex) getImageMetadata
(int imageIndex) getImageTypes
(int imageIndex) int
int
getNumImages
(boolean allowSearch) Overrides the method defined in the superclass.int
int
getWidth
(int imageIndex) boolean
isRandomAccessEasy
(int imageIndex) private boolean
isRaw
(int v) Returns true if file variant is raw format, false if ASCII.read
(int imageIndex, ImageReadParam param) private void
readComments
(ImageInputStream stream, PNMMetadata metadata) Reads the comments.void
private int
readInteger
(ImageInputStream stream) Reads the next integer.readRaster
(int imageIndex, ImageReadParam param) void
reset()
void
Overrides the method defined in the superclass.private void
skipInteger
(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 Details
-
PBM_ASCII
private static final int PBM_ASCII- See Also:
-
PGM_ASCII
private static final int PGM_ASCII- See Also:
-
PPM_ASCII
private static final int PPM_ASCII- See Also:
-
PBM_RAW
private static final int PBM_RAW- See Also:
-
PGM_RAW
private static final int PGM_RAW- See Also:
-
PPM_RAW
private static final int PPM_RAW- See Also:
-
LINE_FEED
private static final int LINE_FEED- See Also:
-
lineSeparator
private static byte[] lineSeparator -
variant
private int variantFile variant: PBM/PGM/PPM, ASCII/RAW. -
maxValue
private int maxValueMaximum pixel value. -
iis
The input stream where reads from -
gotHeader
private boolean gotHeaderIndicates whether the header is read. -
imageDataOffset
private long imageDataOffsetThe stream position where the image data starts. -
width
private int widthThe original image width. -
height
private int heightThe original image height. -
aLine
-
token
-
metadata
-
-
Constructor Details
-
PNMImageReader
ConstructsPNMImageReader
from the providedImageReaderSpi
.
-
-
Method Details
-
setInput
Overrides the method defined in the superclass.- Overrides:
setInput
in classImageReader
-
getNumImages
Overrides the method defined in the superclass.- Specified by:
getNumImages
in classImageReader
- Throws:
IOException
-
getWidth
- Specified by:
getWidth
in classImageReader
- Throws:
IOException
-
getHeight
- Specified by:
getHeight
in classImageReader
- Throws:
IOException
-
getVariant
public int getVariant() -
getMaxValue
public int getMaxValue() -
checkIndex
private void checkIndex(int imageIndex) -
readHeader
- Throws:
IOException
-
getImageTypes
- Specified by:
getImageTypes
in classImageReader
- Throws:
IOException
-
getDefaultReadParam
- Overrides:
getDefaultReadParam
in classImageReader
-
getImageMetadata
- Specified by:
getImageMetadata
in classImageReader
- Throws:
IOException
-
getStreamMetadata
- Specified by:
getStreamMetadata
in classImageReader
- Throws:
IOException
-
isRandomAccessEasy
- Overrides:
isRandomAccessEasy
in classImageReader
- Throws:
IOException
-
read
- Specified by:
read
in classImageReader
- Throws:
IOException
-
canReadRaster
public boolean canReadRaster()- Overrides:
canReadRaster
in classImageReader
-
readRaster
- Overrides:
readRaster
in classImageReader
- Throws:
IOException
-
reset
public void reset()- Overrides:
reset
in classImageReader
-
isRaw
private boolean isRaw(int v) Returns true if file variant is raw format, false if ASCII. -
readComments
Reads the comments.- Throws:
IOException
-
readInteger
Reads the next integer.- Throws:
IOException
-
skipInteger
- Throws:
IOException
-