Top Description Fields Constructors Methods
org.apache.pdfbox.jbig2

public Class Bitmap

extends Object
Class Inheritance
Imports
java.awt.Rectangle, java.util.Arrays

This class represents a bi-level image that is organized like a bitmap.

Field Summary

Modifier and TypeField and Description
private byte[]
bitmap

8 pixels per byte, 0 for white, 1 for black

private final int
height

The height of the bitmap in pixels.

private final int
rowStride

The amount of bytes used per row.

private final int
width

The width of the bitmap in pixels.

Constructor Summary

AccessConstructor and Description
public
Bitmap(int
- The real width of the bitmap in pixels.
width
,
int
- The real height of the bitmap in pixels.
height
)

Creates an instance of a blank image.

Method Summary

Modifier and TypeMethod and Description
public static void
arraycopy(Bitmap
the source Bitmap
src
,
int
start position within the source Bitmap
srcPos
,
Bitmap
the destination Bitmap
dest
,
int
start position within the destination Bitmap
destPos
,
int
the number of bytes to be copied
length
)

Copy parts of the underlying array of a Bitmap to another Bitmap.

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public void
fillBitmap(byte
the value to be stored in all elements of the bitmap
fillByte
)

Fill the underlying bitmap with the given byte value.

public int

Returns:

The bit offset of a pixel in its byte.
getBitOffset
(int
- The x coordinate of a pixel.
x
)

Computes the offset of the given x coordinate in its byte.

public Rectangle
public byte

Returns:

The byte at the index-position.
getByte
(int
- The array index that specifies the position of the wanted byte.
index
)

Simply returns a byte from the bitmap byte array.

public byte[]

Returns:

The byte array of this bitmap.
getByteArray
()
Deprecated don't expose the underlying byte array, will be removed in a future release.

Simply returns the byte array of this bitmap.

public int

Returns:

The converted byte at the index-position as an integer.
getByteAsInteger
(int
- The array index that specifies the position of the wanted byte.
index
)

Converts the byte at specified index into an integer and returns the value.

public int

Returns:

The index of the byte that contains the specified pixel.
getByteIndex
(int
- The pixel's x coordinate.
x
,
int
- The pixel's y coordinate.
y
)

Returns the index of the byte that contains the pixel, specified by the pixel's x and y coordinates.

public int

Returns:

The height of this bitmap.
getHeight
()

Simply returns the height of this bitmap.

public int

Returns:

byte array length
getLength
()

Returns the length of the underlying byte array.

public int

Returns:

byte array length
getMemorySize
()
Deprecated renamed, will be removed in a future release. Use Bitmap#getLength() instead.

Returns the length of the underlying byte array.

public byte

Returns:

The value of a pixel.
getPixel
(int
- The x coordinate of the pixel.
x
,
int
- The y coordinate of the pixel.
y
)

Returns the value of a pixel specified by the given coordinates.

public int

Returns:

The row stride of this bitmap.
getRowStride
()

Simply returns the row stride of this bitmap.

public int

Returns:

The width of this bitmap.
getWidth
()

Simply returns the width of this bitmap.

public void
setByte(int
- The array index that specifies the position of a byte.
index
,
byte
- The byte that should be set.
value
)

Simply sets the given value at the given array index position.

public void
setPixel(int x, int y, byte pixelValue)

Inherited from java.lang.Object:
clonefinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bitmapback to summary
private byte[] bitmap

8 pixels per byte, 0 for white, 1 for black

heightback to summary
private final int height

The height of the bitmap in pixels.

rowStrideback to summary
private final int rowStride

The amount of bytes used per row.

widthback to summary
private final int width

The width of the bitmap in pixels.

Constructor Detail

Bitmapback to summary
public Bitmap(int width, int height)

Creates an instance of a blank image.
The image data is stored in a byte array. Each pixels is stored as one bit, so that each byte contains 8 pixel. A pixel has by default the value 0 for white and 1 for black.
Row stride means the amount of bytes per line. It is computed automatically and fills the pad bits with 0.

Parameters
width:int

- The real width of the bitmap in pixels.

height:int

- The real height of the bitmap in pixels.

Method Detail

arraycopyback to summary
public static void arraycopy(Bitmap src, int srcPos, Bitmap dest, int destPos, int length)

Copy parts of the underlying array of a Bitmap to another Bitmap.

Parameters
src:Bitmap

the source Bitmap

srcPos:int

start position within the source Bitmap

dest:Bitmap

the destination Bitmap

destPos:int

start position within the destination Bitmap

length:int

the number of bytes to be copied

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
fillBitmapback to summary
public void fillBitmap(byte fillByte)

Fill the underlying bitmap with the given byte value.

Parameters
fillByte:byte

the value to be stored in all elements of the bitmap

getBitOffsetback to summary
public int getBitOffset(int x)

Computes the offset of the given x coordinate in its byte. The method uses optimized modulo operation for a better performance.

Parameters
x:int

- The x coordinate of a pixel.

Returns:int

The bit offset of a pixel in its byte.

getBoundsback to summary
public Rectangle getBounds()
getByteback to summary
public byte getByte(int index)

Simply returns a byte from the bitmap byte array. Throws an IndexOutOfBoundsException if the given index is out of bound.

Parameters
index:int

- The array index that specifies the position of the wanted byte.

Returns:byte

The byte at the index-position.

Exceptions
IndexOutOfBoundsException:
if the index is out of bound.
getByteArrayback to summary
public byte[] getByteArray()

Deprecated

don't expose the underlying byte array, will be removed in a future release.

Simply returns the byte array of this bitmap.

Returns:byte[]

The byte array of this bitmap.

getByteAsIntegerback to summary
public int getByteAsInteger(int index)

Converts the byte at specified index into an integer and returns the value. Throws an IndexOutOfBoundsException if the given index is out of bound.

Parameters
index:int

- The array index that specifies the position of the wanted byte.

Returns:int

The converted byte at the index-position as an integer.

Exceptions
IndexOutOfBoundsException:
if the index is out of bound.
getByteIndexback to summary
public int getByteIndex(int x, int y)

Returns the index of the byte that contains the pixel, specified by the pixel's x and y coordinates.

Parameters
x:int

- The pixel's x coordinate.

y:int

- The pixel's y coordinate.

Returns:int

The index of the byte that contains the specified pixel.

getHeightback to summary
public int getHeight()

Simply returns the height of this bitmap.

Returns:int

The height of this bitmap.

getLengthback to summary
public int getLength()

Returns the length of the underlying byte array.

Returns:int

byte array length

getMemorySizeback to summary
public int getMemorySize()

Deprecated

renamed, will be removed in a future release. Use Bitmap#getLength() instead.

Returns the length of the underlying byte array.

Returns:int

byte array length

getPixelback to summary
public byte getPixel(int x, int y)

Returns the value of a pixel specified by the given coordinates.

By default, the value is 0 for a white pixel and 1 for a black pixel. The value is placed in the rightmost bit in the byte.

Parameters
x:int

- The x coordinate of the pixel.

y:int

- The y coordinate of the pixel.

Returns:byte

The value of a pixel.

getRowStrideback to summary
public int getRowStride()

Simply returns the row stride of this bitmap.
(Row stride means the amount of bytes per line.)

Returns:int

The row stride of this bitmap.

getWidthback to summary
public int getWidth()

Simply returns the width of this bitmap.

Returns:int

The width of this bitmap.

setByteback to summary
public void setByte(int index, byte value)

Simply sets the given value at the given array index position. Throws an IndexOutOfBoundsException if the given index is out of bound.

Parameters
index:int

- The array index that specifies the position of a byte.

value:byte

- The byte that should be set.

Exceptions
IndexOutOfBoundsException:
if the index is out of bound.
setPixelback to summary
public void setPixel(int x, int y, byte pixelValue)