Package com.aowagie.text.pdf.codec
Class BmpImage
- java.lang.Object
-
- com.aowagie.text.pdf.codec.BmpImage
-
public class BmpImage extends java.lang.ObjectReads 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 intalphaMaskprivate static intBI_BITFIELDSprivate static intBI_RGBprivate static intBI_RLE4private static intBI_RLE8private longbitmapFileSizeprivate longbitmapOffsetprivate intbitsPerPixelprivate intblueMaskprivate longcompressionprivate intgreenMaskprivate intheightprivate longimageSizeprivate intimageTypeprivate java.io.InputStreaminputStreamprivate booleanisBottomUpprivate static intLCS_CALIBRATED_RGBprivate static intLCS_CMYKprivate static intLCS_sRGBprivate intnumBandsprivate byte[]paletteprivate java.util.HashMappropertiesprivate intredMaskprivate static intVERSION_2_1_BITprivate static intVERSION_2_24_BITprivate static intVERSION_2_4_BITprivate static intVERSION_2_8_BITprivate static intVERSION_3_1_BITprivate static intVERSION_3_24_BITprivate static intVERSION_3_4_BITprivate static intVERSION_3_8_BITprivate static intVERSION_3_NT_16_BITprivate static intVERSION_3_NT_32_BITprivate static intVERSION_4_1_BITprivate static intVERSION_4_16_BITprivate static intVERSION_4_24_BITprivate static intVERSION_4_32_BITprivate static intVERSION_4_4_BITprivate static intVERSION_4_8_BITprivate intwidthprivate longxPelsPerMeterprivate longyPelsPerMeter
-
Constructor Summary
Constructors Modifier Constructor Description privateBmpImage(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 intfindMask(int mask)private intfindShift(int mask)private ImagegetImage()static ImagegetImage(byte[] data)Reads a BMP from a byte array.private static ImagegetImage(java.io.InputStream is)Reads a BMP from a stream.static ImagegetImage(java.io.InputStream is, boolean noHeader, int size)Reads a BMP from a stream.static ImagegetImage(java.net.URL url)Reads a BMP from an url.private byte[]getPalette(int group)private ImageindexedModel(byte[] bdata, int bpc, int paletteEntries)private voidprocess(java.io.InputStream stream, boolean noHeader)private Imageread1632Bit(boolean is32)private Imageread1Bit(int paletteEntries)private voidread24Bit(byte[] bdata)private Imageread4Bit(int paletteEntries)private Imageread8Bit(int paletteEntries)private longreadDWord(java.io.InputStream stream)private intreadInt(java.io.InputStream stream)private intreadLong(java.io.InputStream stream)private voidreadPalette(int sizeOfPalette)private ImagereadRLE4()private ImagereadRLE8()private intreadShort(java.io.InputStream stream)private intreadUnsignedByte(java.io.InputStream stream)private longreadUnsignedInt(java.io.InputStream stream)private intreadUnsignedShort(java.io.InputStream stream)private intreadWord(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
private final java.util.HashMap 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
private int width
-
height
private 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
private 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(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
private 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.IOExceptionBadElementException
-
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.IOExceptionBadElementException
-
read4Bit
private Image read4Bit(int paletteEntries) throws java.io.IOException, BadElementException
- Throws:
java.io.IOExceptionBadElementException
-
read8Bit
private Image read8Bit(int paletteEntries) throws java.io.IOException, BadElementException
- Throws:
java.io.IOExceptionBadElementException
-
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.IOExceptionBadElementException
-
readRLE8
private Image readRLE8() throws java.io.IOException, BadElementException
- Throws:
java.io.IOExceptionBadElementException
-
readRLE4
private Image readRLE4() throws java.io.IOException, BadElementException
- Throws:
java.io.IOExceptionBadElementException
-
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
-
-