public final class Image extends Object implements AutoCloseable
The origin of an image (pixel (0, 0)) is defined at the top left corner, with the x axis pointing right, and the y axis pointing down.
Modifier and Type | Method and Description |
---|---|
android.graphics.Bitmap |
asBitmap() |
void |
close() |
static Image |
create(long width,
long height,
boolean isAlphaPreMultiplied,
PixelFormat pixelFormat,
ByteBuffer data)
Creates an Image.
|
protected void |
finalize() |
static Image |
fromBitmap(android.graphics.Bitmap bitmap)
Creates an Image instance, based on the given bitmap
|
ByteBuffer |
getBytes()
Returns the bytes that make up the pixels of this image.
|
android.graphics.Color |
getColor(long x,
long y)
Returns the color value at the given image location.
|
long |
getHeight()
Returns the height of this image in pixels.
|
PixelFormat |
getPixelFormat()
Returns the pixel format of this image.
|
long |
getWidth()
Returns the width of this image in pixels.
|
boolean |
isAlphaPreMultiplied()
Returns whether the image is using premultiplied alpha.
|
public void close()
close
in interface AutoCloseable
@NotNull public static Image create(long width, long height, boolean isAlphaPreMultiplied, @NotNull PixelFormat pixelFormat, @NotNull ByteBuffer data)
width
- the width of the new imageheight
- the height of the new imageisAlphaPreMultiplied
- true to indicate that the colors in the data buffer contain premultiplied alphapixelFormat
- the pixel formatdata
- the pixel data. The buffer contains rows (left to right) of color data. The rows are ordered from top to bottom. The size of each color, and so also the size of the data buffer, is determined by the used PixelFormat.public long getWidth()
public long getHeight()
@NotNull public PixelFormat getPixelFormat()
public boolean isAlphaPreMultiplied()
@NotNull public ByteBuffer getBytes()
The bytes must be immutable; multiple calls to this method must always result in the same bytes.
The amount of bytes that makes up one pixel depends on the PixelFormat
of this image (see getPixelFormat()
and luciad::sizeInBytes(PixelFormat)
). In other words, the size of this array is equal to: getWidth()
* getHeight()
* luciad::sizeInBytes(getPixelFormat()).
The pixels are arranged in row-major order, starting in the upper-left corner.
@NotNull public android.graphics.Color getColor(long x, long y)
This will be an rgba color for Image
instance with:
PixelFormat#Rgba8888
This will be a greyscale android.graphics.Color for Image
instance with:
x
- the x-coordinate of the pixel. A value of 0 corresponds with a left-most pixel.y
- the y-coordinate of the pixel. A value of 0 corresponds with a top-most pixel.@NotNull public static Image fromBitmap(@NotNull android.graphics.Bitmap bitmap)
bitmap
- a bitmap@NotNull public android.graphics.Bitmap asBitmap()