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 int
private BufferedImage
The destination image.private long
private long
private int
private int
private ColorModel
private long
private int[]
source and destination bands.private Rectangle
The destination region.private boolean
Indicates whether the header is read.private int
private int
The original image height.private ImageInputStream
The input stream where reads fromprivate long
The stream position where the image data starts.private long
private int
private boolean
private BMPMetadata
The metadata from the stream.private boolean
Indicates whether subsampled, subregion is required, and offset is definedprivate int
private ColorModel
private SampleModel
private byte[]
private int
private SampleModel
private int
The scaling factors.private int
The scaling factors.private boolean
Indicates whether subband is selected.private int[]
source and destination bands.private Rectangle
The source region.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 static final int
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 static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private int
The original image width.Fields inherited from class javax.imageio.ImageReader
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales
Fields inherited from interface com.github.jaiimageio.impl.plugins.bmp.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) ConstructsBMPImageReader
from the providedImageReaderSpi
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
private void
checkIndex
(int imageIndex) private void
decodeRLE4
(int imSize, int padding, byte[] values, byte[] bdata) private void
decodeRLE8
(int imSize, int padding, byte[] values, byte[] bdata) int
getHeight
(int imageIndex) getImageMetadata
(int imageIndex) getImageTypes
(int imageIndex) int
getNumImages
(boolean allowSearch) Overrides the method defined in the superclass.int
getWidth
(int imageIndex) boolean
isRandomAccessEasy
(int imageIndex) read
(int imageIndex, ImageReadParam param) private void
read16Bit
(short[] sdata) private void
read1Bit
(byte[] bdata) private void
read24Bit
(byte[] bdata) private void
read32Bit
(int[] idata) private void
read4Bit
(byte[] bdata) private void
read8Bit
(byte[] bdata) private BufferedImage
readEmbedded
(int type, BufferedImage bi, ImageReadParam bmpParam) Decodes the jpeg/png image embedded in the bitmap using any jpeg ImageIO-style plugin.void
readRaster
(int imageIndex, ImageReadParam param) private void
readRLE4
(byte[] bdata) private void
readRLE8
(byte[] bdata) void
reset()
private void
void
Overrides the method defined in the superclass.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
-
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
ConstructsBMPImageReader
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
-
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
-
resetHeaderInfo
private void resetHeaderInfo() -
reset
public void reset()- Overrides:
reset
in 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
- TheImageReadParam
for decoding this BMP image. The parameters for subregion, band selection and subsampling are used in decoding the jpeg image.- Throws:
IOException
-