public class Bitmap extends Object
| Constructor and Description |
|---|
Bitmap(int width,
int height)
Creates an instance of a blank image.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
boolean |
equals(Object obj) |
void |
fillBitmap(byte fillByte)
Fill the underlying bitmap with the given byte value.
|
int |
getBitOffset(int x)
Computes the offset of the given x coordinate in its byte.
|
Rectangle |
getBounds() |
byte |
getByte(int index)
Simply returns a byte from the bitmap byte array.
|
byte[] |
getByteArray()
Deprecated.
don't expose the underlying byte array, will be removed in a future release.
|
int |
getByteAsInteger(int index)
Converts the byte at specified index into an integer and returns the value.
|
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.
|
int |
getHeight()
Simply returns the height of this bitmap.
|
int |
getLength()
Returns the length of the underlying byte array.
|
int |
getMemorySize()
Deprecated.
renamed, will be removed in a future release. Use
getLength() instead. |
byte |
getPixel(int x,
int y)
Returns the value of a pixel specified by the given coordinates.
|
int |
getRowStride()
Simply returns the row stride of this bitmap.
|
int |
getWidth()
Simply returns the width of this bitmap.
|
int |
hashCode() |
void |
setByte(int index,
byte value)
Simply sets the given value at the given array index position.
|
void |
setPixel(int x,
int y,
byte pixelValue)
Sets the value of a pixel specified by the given coordinates.
|
public Bitmap(int width,
int height)
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.
height - - The real height of the bitmap in pixels.width - - The real width of the bitmap in pixels.public byte getPixel(int x,
int y)
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.
There is no check whether the pixel coordinate is within the bitmap.
x - - The x coordinate of the pixel.y - - The y coordinate of the pixel.public void setPixel(int x,
int y,
byte pixelValue)
By default, the value is 0 for a white pixel and 1 for a black pixel. The
value is taken from the rightmost bit in the byte.
There is no check whether the pixel coordinate is within the bitmap.
x - - The x coordinate of the pixel.y - - The y coordinate of the pixel.pixelValue - The value of a pixel.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.
x - - The pixel's x coordinate.y - - The pixel's y coordinate.@Deprecated public byte[] getByteArray()
public byte getByte(int index)
IndexOutOfBoundsException if the given index
is out of bound.index - - The array index that specifies the position of the wanted byte.index-position.IndexOutOfBoundsException - if the index is out of bound.public void setByte(int index,
byte value)
IndexOutOfBoundsException if the
given index is out of bound.index - - The array index that specifies the position of a byte.value - - The byte that should be set.IndexOutOfBoundsException - if the index is out of bound.public int getByteAsInteger(int index)
IndexOutOfBoundsException if the given index is out of bound.index - - The array index that specifies the position of the wanted byte.index-position as an integer.IndexOutOfBoundsException - if the index is out of bound.public int getBitOffset(int x)
x - - The x coordinate of a pixel.public int getHeight()
public int getWidth()
public int getRowStride()
public Rectangle getBounds()
@Deprecated public int getMemorySize()
getLength() instead.public int getLength()
public void fillBitmap(byte fillByte)
fillByte - the value to be stored in all elements of the bitmappublic static void arraycopy(Bitmap src, int srcPos, Bitmap dest, int destPos, int length)
src - the source BitmapsrcPos - start position within the source Bitmapdest - the destination BitmapdestPos - start position within the destination Bitmaplength - the number of bytes to be copiedCopyright © 2026 The Apache Software Foundation. All rights reserved.