java.lang.Object | |
↳ | com.carto.graphics.Bitmap |
A class that provides the functionality to store, compress, uncompress and resize basic image formats.
Currently supported formats are png and jpeg. Upon loading compressed images will be converted to
alpha premultiplied uncompressed bitmaps of various image formats.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Bitmap(BinaryData pixelData, long width, long height, ColorFormat colorFormat, int bytesPerRow)
Constructs a bitmap from an already decoded vector of bytes.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
BinaryData |
compressToInternal()
Compresses this bitmap to a internal format.
| ||||||||||
BinaryData |
compressToPNG()
Compresses this bitmap to a PNG format.
| ||||||||||
static Bitmap |
createFromCompressed(BinaryData compressedData)
Creates a new bitmap from compressed byte vector.
| ||||||||||
synchronized void | delete() | ||||||||||
boolean |
equals(Object obj)
Checks if this object is equal to the specified object.
| ||||||||||
long |
getBytesPerPixel()
Returns the bytes per pixel parameter of this bitmap.
| ||||||||||
ColorFormat |
getColorFormat()
Returns the color format of this bitmap.
| ||||||||||
long |
getHeight()
Returns the height of the bitmap.
| ||||||||||
Bitmap |
getPaddedBitmap(int xPadding, int yPadding)
Returns paddedsub-bitmap with specified offsets and dimensions.
| ||||||||||
BinaryData |
getPixelData()
Returns a copy of the pixel data of this bitmap.
| ||||||||||
Bitmap |
getRGBABitmap()
Returns copy of the bitmap converted to RGBA format.
| ||||||||||
Bitmap |
getResizedBitmap(long width, long height)
Returns resized version of the bitmap.
| ||||||||||
Bitmap |
getSubBitmap(int xOffset, int yOffset, int width, int height)
Returns sub-bitmap with specified offsets and dimensions.
| ||||||||||
long |
getWidth()
Returns the width of the bitmap.
| ||||||||||
int |
hashCode()
Returns the hash value of this object.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Constructs a bitmap from an already decoded vector of bytes. The bitmap data is expected to be alpha premultiplied, if alpha channel is used.
If the power of two conversion flag is set, additional padding will be added to the image to make it's dimensions power of two.
This can be useful when creating OpenGL textures from the Bitmap, because some GPUs perform badly with non power of two textures.
pixelData | A vector of decoded, premultiplied bitmap bytes. |
---|---|
width | The width of the bitmap. |
height | The height of the bitmap. |
colorFormat | The color format of the bitmap. |
bytesPerRow | The total number of bytes per row. Some bitmaps have additional padding at the end of each row. If the value is negative, then bitmap is assumed to be vertically flipped. In this case absolute value of the bytesPerRow value is used. |
Compresses this bitmap to a internal format.
This operation is intended for serialization of the data only, no actual compression is performed.
Compresses this bitmap to a PNG format.
Creates a new bitmap from compressed byte vector.
If the power of two conversion flag is set, additional padding will be added to the image to make it's dimensions power of two.
compressedData | The compressed bitmap data. |
---|
Checks if this object is equal to the specified object.
obj | The reference object. |
---|
Returns the bytes per pixel parameter of this bitmap. Valid values are 1, 2, 3 and 4.
Returns the color format of this bitmap.
Returns the height of the bitmap.
Returns paddedsub-bitmap with specified offsets and dimensions.
xPadding | Padding along X coordinate. If negative value is used, the bitmap is padded from the left. By default, bitmap is padded from the right. |
---|---|
yPadding | Padding along Y coordinate. If negative value is used, the bitmap is padded from the top. By default, bitmap is padded from the bottom. |
Returns a copy of the pixel data of this bitmap.
Returns copy of the bitmap converted to RGBA format.
Returns resized version of the bitmap. The power of two padding added during the construction of this bitmap
will be removed prior to resizing. If the power of two conversion flag is set, new padding will be added to the image
after resizing to make it's dimensions power of two.
width | The new width of this bitmap. |
---|---|
height | The new height of this bitmap. |
Returns sub-bitmap with specified offsets and dimensions.
xOffset | X coordinate offset in the bitmap. |
---|---|
yOffset | Y coordinate offset in the bitmap. |
width | Width of the sub-bitmap. |
height | Height of the sub-bitmap. |
Returns the width of the bitmap.
Returns the hash value of this object.