public static class ImageExtractor.BmpFileReader extends java.lang.Object implements ImageExtractor.ImageReader
Modifier and Type | Field and Description |
---|---|
static byte |
BITMAPINFOHEADER_MARKER
Represents the size of BITMAPINFOHEADER marker.
|
static byte[] |
BM_MARKER
Represents the first two bytes of a BMP image file.
|
private int |
imageSize
Stores the image data size.
|
private int |
index
Stores the current index.
|
private byte[] |
output
Stores the extracted image data.
|
Constructor and Description |
---|
BmpFileReader() |
Modifier and Type | Method and Description |
---|---|
byte[] |
getImageData()
Returns the binary image data.
|
java.lang.String |
getImageFileExtension()
Returns the BMP image standard extension.
|
int |
getImageIndex()
Returns the current image count as its index value, a 1-based index.
|
private boolean |
hasMarker(byte firstByte,
byte secondByte)
Test if the first two bytes can be the beginning of the bmp data.
|
boolean |
nextImage(java.io.RandomAccessFile raf)
Extracts a first available BMP image data starting from the current file offset.
|
private int |
readImageSize(java.io.RandomAccessFile raf)
Try to read the next 4 bytes and interprets the data as little-endian data that stores
the bmp image size.
|
public static final byte[] BM_MARKER
public static final byte BITMAPINFOHEADER_MARKER
private byte[] output
private int imageSize
private int index
public boolean nextImage(java.io.RandomAccessFile raf) throws java.io.IOException
nextImage
in interface ImageExtractor.ImageReader
raf
- The data represented by the random access filejava.io.IOException
- If IO error occurs while reading data and moving the current file pointer.public byte[] getImageData()
getImageData
in interface ImageExtractor.ImageReader
public int getImageIndex()
getImageIndex
in interface ImageExtractor.ImageReader
public java.lang.String getImageFileExtension()
getImageFileExtension
in interface ImageExtractor.ImageReader
private boolean hasMarker(byte firstByte, byte secondByte)
firstByte
- The first bytesecondByte
- The second byteprivate int readImageSize(java.io.RandomAccessFile raf) throws java.io.IOException
raf
- The data represented by the random access filejava.io.IOException
- Iff IO error occurs during this reading operation.