com.lowagie.text.pdf.codec

Class BmpImage

public class BmpImage extends Object

Reads a BMP image. All types of BMP can be read.

It is based in the JAI codec.

Author: Paulo Soares (psoares@consiste.pt)

Field Summary
intalphaMask
longbitmapFileSize
longbitmapOffset
intbitsPerPixel
intblueMask
static intBI_BITFIELDS
static intBI_RGB
static intBI_RLE4
static intBI_RLE8
longcompression
intgreenMask
intheight
longimageSize
intimageType
InputStreaminputStream
booleanisBottomUp
static intLCS_CALIBRATED_RGB
static intLCS_CMYK
static intLCS_sRGB
intnumBands
byte[]palette
HashMapproperties
intredMask
static intVERSION_2_1_BIT
static intVERSION_2_24_BIT
static intVERSION_2_4_BIT
static intVERSION_2_8_BIT
static intVERSION_3_1_BIT
static intVERSION_3_24_BIT
static intVERSION_3_4_BIT
static intVERSION_3_8_BIT
static intVERSION_3_NT_16_BIT
static intVERSION_3_NT_32_BIT
static intVERSION_4_16_BIT
static intVERSION_4_1_BIT
static intVERSION_4_24_BIT
static intVERSION_4_32_BIT
static intVERSION_4_4_BIT
static intVERSION_4_8_BIT
intwidth
longxPelsPerMeter
longyPelsPerMeter
Constructor Summary
BmpImage(InputStream is, boolean noHeader, int size)
Method Summary
byte[]decodeRLE(boolean is8, byte[] values)
intfindMask(int mask)
intfindShift(int mask)
static ImagegetImage(URL url)
Reads a BMP from an url.
static ImagegetImage(InputStream is)
Reads a BMP from a stream.
static ImagegetImage(InputStream is, boolean noHeader, int size)
Reads a BMP from a stream.
static ImagegetImage(String file)
Reads a BMP from a file.
static ImagegetImage(byte[] data)
Reads a BMP from a byte array.
ImagegetImage()
byte[]getPalette(int group)
ImageindexedModel(byte[] bdata, int bpc, int paletteEntries)
protected voidprocess(InputStream stream, boolean noHeader)
Imageread1632Bit(boolean is32)
Imageread1Bit(int paletteEntries)
voidread24Bit(byte[] bdata)
Imageread4Bit(int paletteEntries)
Imageread8Bit(int paletteEntries)
longreadDWord(InputStream stream)
intreadInt(InputStream stream)
intreadLong(InputStream stream)
voidreadPalette(int sizeOfPalette)
ImagereadRLE4()
ImagereadRLE8()
intreadShort(InputStream stream)
intreadUnsignedByte(InputStream stream)
longreadUnsignedInt(InputStream stream)
intreadUnsignedShort(InputStream stream)
intreadWord(InputStream stream)

Field Detail

alphaMask

private int alphaMask

bitmapFileSize

private long bitmapFileSize

bitmapOffset

private long bitmapOffset

bitsPerPixel

private int bitsPerPixel

blueMask

private int blueMask

BI_BITFIELDS

private static final int BI_BITFIELDS

BI_RGB

private static final int BI_RGB

BI_RLE4

private static final int BI_RLE4

BI_RLE8

private static final int BI_RLE8

compression

private long compression

greenMask

private int greenMask

height

int height

imageSize

private long imageSize

imageType

private int imageType

inputStream

private InputStream inputStream

isBottomUp

private boolean isBottomUp

LCS_CALIBRATED_RGB

private static final int LCS_CALIBRATED_RGB

LCS_CMYK

private static final int LCS_CMYK

LCS_sRGB

private static final int LCS_sRGB

numBands

private int numBands

palette

private byte[] palette

properties

public HashMap properties

redMask

private int redMask

VERSION_2_1_BIT

private static final int VERSION_2_1_BIT

VERSION_2_24_BIT

private static final int VERSION_2_24_BIT

VERSION_2_4_BIT

private static final int VERSION_2_4_BIT

VERSION_2_8_BIT

private static final int VERSION_2_8_BIT

VERSION_3_1_BIT

private static final int VERSION_3_1_BIT

VERSION_3_24_BIT

private static final int VERSION_3_24_BIT

VERSION_3_4_BIT

private static final int VERSION_3_4_BIT

VERSION_3_8_BIT

private static final int VERSION_3_8_BIT

VERSION_3_NT_16_BIT

private static final int VERSION_3_NT_16_BIT

VERSION_3_NT_32_BIT

private static final int VERSION_3_NT_32_BIT

VERSION_4_16_BIT

private static final int VERSION_4_16_BIT

VERSION_4_1_BIT

private static final int VERSION_4_1_BIT

VERSION_4_24_BIT

private static final int VERSION_4_24_BIT

VERSION_4_32_BIT

private static final int VERSION_4_32_BIT

VERSION_4_4_BIT

private static final int VERSION_4_4_BIT

VERSION_4_8_BIT

private static final int VERSION_4_8_BIT

width

int width

xPelsPerMeter

private long xPelsPerMeter

yPelsPerMeter

private long yPelsPerMeter

Constructor Detail

BmpImage

BmpImage(InputStream is, boolean noHeader, int size)

Method Detail

decodeRLE

private byte[] decodeRLE(boolean is8, byte[] values)

findMask

private int findMask(int mask)

findShift

private int findShift(int mask)

getImage

public static Image getImage(URL url)
Reads a BMP from an url.

Parameters: url the url

Returns: the image

Throws: IOException on error

getImage

public static Image getImage(InputStream is)
Reads a BMP from a stream. The stream is not closed.

Parameters: is the stream

Returns: the image

Throws: IOException on error

getImage

public static Image getImage(InputStream is, boolean noHeader, int size)
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 stream noHeader true to process a plain DIB size the size of the DIB. Not used for a BMP

Returns: the image

Throws: IOException on error

getImage

public static Image getImage(String file)
Reads a BMP from a file.

Parameters: file the file

Returns: the image

Throws: IOException on error

getImage

public static Image getImage(byte[] data)
Reads a BMP from a byte array.

Parameters: data the byte array

Returns: the image

Throws: IOException on error

getImage

private Image getImage()

getPalette

private byte[] getPalette(int group)

indexedModel

private Image indexedModel(byte[] bdata, int bpc, int paletteEntries)

process

protected void process(InputStream stream, boolean noHeader)

read1632Bit

private Image read1632Bit(boolean is32)

read1Bit

private Image read1Bit(int paletteEntries)

read24Bit

private void read24Bit(byte[] bdata)

read4Bit

private Image read4Bit(int paletteEntries)

read8Bit

private Image read8Bit(int paletteEntries)

readDWord

private long readDWord(InputStream stream)

readInt

private int readInt(InputStream stream)

readLong

private int readLong(InputStream stream)

readPalette

private void readPalette(int sizeOfPalette)

readRLE4

private Image readRLE4()

readRLE8

private Image readRLE8()

readShort

private int readShort(InputStream stream)

readUnsignedByte

private int readUnsignedByte(InputStream stream)

readUnsignedInt

private long readUnsignedInt(InputStream stream)

readUnsignedShort

private int readUnsignedShort(InputStream stream)

readWord

private int readWord(InputStream stream)