Package com.itextpdf.text.pdf.codec
Class BmpImage
- java.lang.Object
-
- com.itextpdf.text.pdf.codec.BmpImage
-
public class BmpImage extends java.lang.Object
Reads a BMP image. All types of BMP can be read.It is based in the JAI codec.
-
-
Field Summary
Fields Modifier and Type Field Description private int
alphaMask
private static int
BI_BITFIELDS
private static int
BI_RGB
private static int
BI_RLE4
private static int
BI_RLE8
private long
bitmapFileSize
private long
bitmapOffset
private int
bitsPerPixel
private int
blueMask
private long
compression
private int
greenMask
(package private) int
height
private long
imageSize
private int
imageType
private java.io.InputStream
inputStream
private boolean
isBottomUp
private static int
LCS_CALIBRATED_RGB
private static int
LCS_CMYK
private static int
LCS_sRGB
private int
numBands
private byte[]
palette
java.util.HashMap<java.lang.String,java.lang.Object>
properties
private int
redMask
private static int
VERSION_2_1_BIT
private static int
VERSION_2_24_BIT
private static int
VERSION_2_4_BIT
private static int
VERSION_2_8_BIT
private static int
VERSION_3_1_BIT
private static int
VERSION_3_24_BIT
private static int
VERSION_3_4_BIT
private static int
VERSION_3_8_BIT
private static int
VERSION_3_NT_16_BIT
private static int
VERSION_3_NT_32_BIT
private static int
VERSION_4_1_BIT
private static int
VERSION_4_16_BIT
private static int
VERSION_4_24_BIT
private static int
VERSION_4_32_BIT
private static int
VERSION_4_4_BIT
private static int
VERSION_4_8_BIT
(package private) int
width
private long
xPelsPerMeter
private long
yPelsPerMeter
-
Constructor Summary
Constructors Constructor Description BmpImage(java.io.InputStream is, boolean noHeader, int size)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private byte[]
decodeRLE(boolean is8, byte[] values)
private int
findMask(int mask)
private int
findShift(int mask)
private Image
getImage()
static Image
getImage(byte[] data)
Reads a BMP from a byte array.static Image
getImage(java.io.InputStream is)
Reads a BMP from a stream.static Image
getImage(java.io.InputStream is, boolean noHeader, int size)
Reads a BMP from a stream.static Image
getImage(java.lang.String file)
Reads a BMP from a file.static Image
getImage(java.net.URL url)
Reads a BMP from an url.private byte[]
getPalette(int group)
private Image
indexedModel(byte[] bdata, int bpc, int paletteEntries)
protected void
process(java.io.InputStream stream, boolean noHeader)
private Image
read1632Bit(boolean is32)
private Image
read1Bit(int paletteEntries)
private void
read24Bit(byte[] bdata)
private Image
read4Bit(int paletteEntries)
private Image
read8Bit(int paletteEntries)
private long
readDWord(java.io.InputStream stream)
private int
readInt(java.io.InputStream stream)
private int
readLong(java.io.InputStream stream)
private void
readPalette(int sizeOfPalette)
private Image
readRLE4()
private Image
readRLE8()
private int
readShort(java.io.InputStream stream)
private int
readUnsignedByte(java.io.InputStream stream)
private long
readUnsignedInt(java.io.InputStream stream)
private int
readUnsignedShort(java.io.InputStream stream)
private int
readWord(java.io.InputStream stream)
-
-
-
Field Detail
-
inputStream
private java.io.InputStream inputStream
-
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
-
properties
public java.util.HashMap<java.lang.String,java.lang.Object> properties
-
xPelsPerMeter
private long xPelsPerMeter
-
yPelsPerMeter
private long yPelsPerMeter
-
VERSION_2_1_BIT
private static final int VERSION_2_1_BIT
- See Also:
- Constant Field Values
-
VERSION_2_4_BIT
private static final int VERSION_2_4_BIT
- See Also:
- Constant Field Values
-
VERSION_2_8_BIT
private static final int VERSION_2_8_BIT
- See Also:
- Constant Field Values
-
VERSION_2_24_BIT
private static final int VERSION_2_24_BIT
- See Also:
- Constant Field Values
-
VERSION_3_1_BIT
private static final int VERSION_3_1_BIT
- See Also:
- Constant Field Values
-
VERSION_3_4_BIT
private static final int VERSION_3_4_BIT
- See Also:
- Constant Field Values
-
VERSION_3_8_BIT
private static final int VERSION_3_8_BIT
- See Also:
- Constant Field Values
-
VERSION_3_24_BIT
private static final int VERSION_3_24_BIT
- See Also:
- Constant Field Values
-
VERSION_3_NT_16_BIT
private static final int VERSION_3_NT_16_BIT
- See Also:
- Constant Field Values
-
VERSION_3_NT_32_BIT
private static final int VERSION_3_NT_32_BIT
- See Also:
- Constant Field Values
-
VERSION_4_1_BIT
private static final int VERSION_4_1_BIT
- See Also:
- Constant Field Values
-
VERSION_4_4_BIT
private static final int VERSION_4_4_BIT
- See Also:
- Constant Field Values
-
VERSION_4_8_BIT
private static final int VERSION_4_8_BIT
- See Also:
- Constant Field Values
-
VERSION_4_16_BIT
private static final int VERSION_4_16_BIT
- See Also:
- Constant Field Values
-
VERSION_4_24_BIT
private static final int VERSION_4_24_BIT
- See Also:
- Constant Field Values
-
VERSION_4_32_BIT
private static final int VERSION_4_32_BIT
- See Also:
- Constant Field Values
-
LCS_CALIBRATED_RGB
private static final int LCS_CALIBRATED_RGB
- See Also:
- Constant Field Values
-
LCS_sRGB
private static final int LCS_sRGB
- See Also:
- Constant Field Values
-
LCS_CMYK
private static final int LCS_CMYK
- See Also:
- Constant Field Values
-
BI_RGB
private static final int BI_RGB
- See Also:
- Constant Field Values
-
BI_RLE8
private static final int BI_RLE8
- See Also:
- Constant Field Values
-
BI_RLE4
private static final int BI_RLE4
- See Also:
- Constant Field Values
-
BI_BITFIELDS
private static final int BI_BITFIELDS
- See Also:
- Constant Field Values
-
width
int width
-
height
int height
-
-
Method Detail
-
getImage
public static Image getImage(java.net.URL url) throws java.io.IOException
Reads a BMP from an url.- Parameters:
url
- the url- Returns:
- the image
- Throws:
java.io.IOException
- on error
-
getImage
public static Image getImage(java.io.InputStream is) throws java.io.IOException
Reads a BMP from a stream. The stream is not closed.- Parameters:
is
- the stream- Returns:
- the image
- Throws:
java.io.IOException
- on error
-
getImage
public static Image getImage(java.io.InputStream is, boolean noHeader, int size) throws java.io.IOException
Reads a BMP from a stream. The stream is not closed. The BMP may not have a header and be considered as a plain DIB.- Parameters:
is
- the streamnoHeader
- true to process a plain DIBsize
- the size of the DIB. Not used for a BMP- Returns:
- the image
- Throws:
java.io.IOException
- on error
-
getImage
public static Image getImage(java.lang.String file) throws java.io.IOException
Reads a BMP from a file.- Parameters:
file
- the file- Returns:
- the image
- Throws:
java.io.IOException
- on error
-
getImage
public static Image getImage(byte[] data) throws java.io.IOException
Reads a BMP from a byte array.- Parameters:
data
- the byte array- Returns:
- the image
- Throws:
java.io.IOException
- on error
-
process
protected void process(java.io.InputStream stream, boolean noHeader) throws java.io.IOException
- Throws:
java.io.IOException
-
getPalette
private byte[] getPalette(int group)
-
getImage
private Image getImage() throws java.io.IOException, BadElementException
- Throws:
java.io.IOException
BadElementException
-
indexedModel
private Image indexedModel(byte[] bdata, int bpc, int paletteEntries) throws BadElementException
- Throws:
BadElementException
-
readPalette
private void readPalette(int sizeOfPalette) throws java.io.IOException
- Throws:
java.io.IOException
-
read1Bit
private Image read1Bit(int paletteEntries) throws java.io.IOException, BadElementException
- Throws:
java.io.IOException
BadElementException
-
read4Bit
private Image read4Bit(int paletteEntries) throws java.io.IOException, BadElementException
- Throws:
java.io.IOException
BadElementException
-
read8Bit
private Image read8Bit(int paletteEntries) throws java.io.IOException, BadElementException
- Throws:
java.io.IOException
BadElementException
-
read24Bit
private void read24Bit(byte[] bdata)
-
findMask
private int findMask(int mask)
-
findShift
private int findShift(int mask)
-
read1632Bit
private Image read1632Bit(boolean is32) throws java.io.IOException, BadElementException
- Throws:
java.io.IOException
BadElementException
-
readRLE8
private Image readRLE8() throws java.io.IOException, BadElementException
- Throws:
java.io.IOException
BadElementException
-
readRLE4
private Image readRLE4() throws java.io.IOException, BadElementException
- Throws:
java.io.IOException
BadElementException
-
decodeRLE
private byte[] decodeRLE(boolean is8, byte[] values)
-
readUnsignedByte
private int readUnsignedByte(java.io.InputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
readUnsignedShort
private int readUnsignedShort(java.io.InputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
readShort
private int readShort(java.io.InputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
readWord
private int readWord(java.io.InputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
readUnsignedInt
private long readUnsignedInt(java.io.InputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
readInt
private int readInt(java.io.InputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
readDWord
private long readDWord(java.io.InputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
readLong
private int readLong(java.io.InputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
-