Class BMPImageReader
java.lang.Object
javax.imageio.ImageReader
com.github.jaiimageio.impl.plugins.bmp.BMPImageReader
- All Implemented Interfaces:
BMPConstants
This class is the Java Image IO plugin reader for BMP 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
ImageReadParam.
This class supports Microsoft Windows Bitmap Version 3-5,
as well as OS/2 Bitmap Version 2.x (for single-image BMP file).-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate BufferedImageThe destination image.private longprivate longprivate intprivate intprivate ColorModelprivate longprivate int[]source and destination bands.private RectangleThe destination region.private booleanIndicates whether the header is read.private intprivate intThe original image height.private ImageInputStreamThe input stream where reads fromprivate longThe stream position where the image data starts.private longprivate intprivate booleanprivate BMPMetadataThe metadata from the stream.private booleanIndicates whether subsampled, subregion is required, and offset is definedprivate intprivate ColorModelprivate SampleModelprivate byte[]private intprivate SampleModelprivate intThe scaling factors.private intThe scaling factors.private booleanIndicates whether subband is selected.private int[]source and destination bands.private RectangleThe source region.private static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate intThe original image width.Fields inherited from class ImageReader
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocalesFields inherited from interface BMPConstants
BI_BITFIELDS, BI_JPEG, BI_PNG, BI_RGB, BI_RLE4, BI_RLE8, compressionTypeNames, LCS_CALIBRATED_RGB, LCS_sRGB, LCS_WINDOWS_COLOR_SPACE, PROFILE_EMBEDDED, PROFILE_LINKED, VERSION_2, VERSION_3, VERSION_3_NT, VERSION_4, VERSION_5 -
Constructor Summary
ConstructorsConstructorDescriptionBMPImageReader(ImageReaderSpi originator) ConstructsBMPImageReaderfrom the providedImageReaderSpi. -
Method Summary
Modifier and TypeMethodDescriptionbooleanprivate voidcheckIndex(int imageIndex) private voiddecodeRLE4(int imSize, int padding, byte[] values, byte[] bdata) private voiddecodeRLE8(int imSize, int padding, byte[] values, byte[] bdata) intgetHeight(int imageIndex) getImageMetadata(int imageIndex) getImageTypes(int imageIndex) intgetNumImages(boolean allowSearch) Overrides the method defined in the superclass.intgetWidth(int imageIndex) booleanisRandomAccessEasy(int imageIndex) read(int imageIndex, ImageReadParam param) private voidread16Bit(short[] sdata) private voidread1Bit(byte[] bdata) private voidread24Bit(byte[] bdata) private voidread32Bit(int[] idata) private voidread4Bit(byte[] bdata) private voidread8Bit(byte[] bdata) private BufferedImagereadEmbedded(int type, BufferedImage bi, ImageReadParam bmpParam) Decodes the jpeg/png image embedded in the bitmap using any jpeg ImageIO-style plugin.voidreadRaster(int imageIndex, ImageReadParam param) private voidreadRLE4(byte[] bdata) private voidreadRLE8(byte[] bdata) voidreset()private voidvoidOverrides the method defined in the superclass.Methods inherited from class 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
-
VERSION_2_1_BIT
private static final int VERSION_2_1_BIT- See Also:
-
VERSION_2_4_BIT
private static final int VERSION_2_4_BIT- See Also:
-
VERSION_2_8_BIT
private static final int VERSION_2_8_BIT- See Also:
-
VERSION_2_24_BIT
private static final int VERSION_2_24_BIT- See Also:
-
VERSION_3_1_BIT
private static final int VERSION_3_1_BIT- See Also:
-
VERSION_3_4_BIT
private static final int VERSION_3_4_BIT- See Also:
-
VERSION_3_8_BIT
private static final int VERSION_3_8_BIT- See Also:
-
VERSION_3_24_BIT
private static final int VERSION_3_24_BIT- See Also:
-
VERSION_3_NT_16_BIT
private static final int VERSION_3_NT_16_BIT- See Also:
-
VERSION_3_NT_32_BIT
private static final int VERSION_3_NT_32_BIT- See Also:
-
VERSION_4_1_BIT
private static final int VERSION_4_1_BIT- See Also:
-
VERSION_4_4_BIT
private static final int VERSION_4_4_BIT- See Also:
-
VERSION_4_8_BIT
private static final int VERSION_4_8_BIT- See Also:
-
VERSION_4_16_BIT
private static final int VERSION_4_16_BIT- See Also:
-
VERSION_4_24_BIT
private static final int VERSION_4_24_BIT- See Also:
-
VERSION_4_32_BIT
private static final int VERSION_4_32_BIT- See Also:
-
VERSION_3_XP_EMBEDDED
private static final int VERSION_3_XP_EMBEDDED- See Also:
-
VERSION_4_XP_EMBEDDED
private static final int VERSION_4_XP_EMBEDDED- See Also:
-
VERSION_5_XP_EMBEDDED
private static final int VERSION_5_XP_EMBEDDED- See Also:
-
bitmapFileSize
private long bitmapFileSize -
bitmapOffset
private long bitmapOffset -
compression
private long compression -
imageSize
private long imageSize -
palette
private byte[] palette -
imageType
private int imageType -
numBands
private int numBands -
isBottomUp
private boolean isBottomUp -
bitsPerPixel
private int bitsPerPixel -
redMask
private int redMask -
greenMask
private int greenMask -
blueMask
private int blueMask -
alphaMask
private int alphaMask -
sampleModel
-
originalSampleModel
-
colorModel
-
originalColorModel
-
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. -
destinationRegion
The destination region. -
sourceRegion
The source region. -
metadata
The metadata from the stream. -
bi
The destination image. -
noTransform
private boolean noTransformIndicates whether subsampled, subregion is required, and offset is defined -
seleBand
private boolean seleBandIndicates whether subband is selected. -
scaleX
private int scaleXThe scaling factors. -
scaleY
private int scaleYThe scaling factors. -
sourceBands
private int[] sourceBandssource and destination bands. -
destBands
private int[] destBandssource and destination bands.
-
-
Constructor Details
-
BMPImageReader
ConstructsBMPImageReaderfrom the providedImageReaderSpi.
-
-
Method Details
-
setInput
Overrides the method defined in the superclass.- Overrides:
setInputin classImageReader
-
getNumImages
Overrides the method defined in the superclass.- Specified by:
getNumImagesin classImageReader- Throws:
IOException
-
getWidth
- Specified by:
getWidthin classImageReader- Throws:
IOException
-
getHeight
- Specified by:
getHeightin classImageReader- Throws:
IOException
-
checkIndex
private void checkIndex(int imageIndex) -
readHeader
- Throws:
IOException
-
getImageTypes
- Specified by:
getImageTypesin classImageReader- Throws:
IOException
-
getDefaultReadParam
- Overrides:
getDefaultReadParamin classImageReader
-
getImageMetadata
- Specified by:
getImageMetadatain classImageReader- Throws:
IOException
-
getStreamMetadata
- Specified by:
getStreamMetadatain classImageReader- Throws:
IOException
-
isRandomAccessEasy
- Overrides:
isRandomAccessEasyin classImageReader- Throws:
IOException
-
read
- Specified by:
readin classImageReader- Throws:
IOException
-
canReadRaster
public boolean canReadRaster()- Overrides:
canReadRasterin classImageReader
-
readRaster
- Overrides:
readRasterin classImageReader- Throws:
IOException
-
resetHeaderInfo
private void resetHeaderInfo() -
reset
public void reset()- Overrides:
resetin classImageReader
-
read1Bit
- Throws:
IOException
-
read4Bit
- Throws:
IOException
-
read8Bit
- Throws:
IOException
-
read24Bit
- Throws:
IOException
-
read16Bit
- Throws:
IOException
-
read32Bit
- Throws:
IOException
-
readRLE8
- Throws:
IOException
-
decodeRLE8
- Throws:
IOException
-
readRLE4
- Throws:
IOException
-
decodeRLE4
- Throws:
IOException
-
readEmbedded
private BufferedImage readEmbedded(int type, BufferedImage bi, ImageReadParam bmpParam) throws IOException Decodes the jpeg/png image embedded in the bitmap using any jpeg ImageIO-style plugin.- Parameters:
bi- The destinationBufferedImage.bmpParam- TheImageReadParamfor decoding this BMP image. The parameters for subregion, band selection and subsampling are used in decoding the jpeg image.- Throws:
IOException
-