Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class Raster
- Object
- Raster
A rectangle of non-premultiplied 0xAARRGGBB pixels with a position.
The renderer paints every layer into a Raster and composites them with Compositor, so
a document looks the same on every port and in tests that have no display.
Fields
public static final int MAX_PIXELS = 67108864 | The largest number of pixels a raster may hold: 64 megapixels. |
Constructors
public Raster(int x, int y, int width, int height) | Creates a transparent raster. |
public Raster(int x, int y, int width, int height, int[] pixels) | Wraps existing pixels. |
Methods
public int getX() | Left edge. |
public int getY() | Top edge. |
public int getWidth() | Width in pixels. |
public int getHeight() | Height in pixels. |
public int[] getPixels() | The pixel array, row major. |
public int get(int px, int py) | The pixel at absolute coordinates, transparent outside. |
public Raster copy() | A deep copy. |
public boolean isEmpty() | True when every pixel is fully transparent. |
public Raster resize(int nx, int ny, int nw, int nh) | Returns a raster covering [nx, ny, nw, nh] with this one’s pixels copied in. |
public void composite(Raster src, BlendMode mode, float opacity) | Composites src onto this raster where they overlap. |
public void applyMask(byte[] mask) | Multiplies each pixel’s alpha by a coverage mask of the same geometry (0..255). |
public Raster transform(Matrix m, int[] clip) | Returns this raster drawn through a transform, sampled bilinearly, clipped to the device rectangle clip (x, y, w, h) when it is not null. |
Inherited methods
Field details
MAX_PIXELS
public static final int MAX_PIXELS = 67108864The largest number of pixels a raster may hold: 64 megapixels.
Constructor details
Raster
public Raster(int x, int y, int width, int height)Creates a transparent raster.
Parameters
xint- left edge in device pixels
yint- top edge in device pixels
widthint- width, at least 0
heightint- height, at least 0
Raster
public Raster(int x, int y, int width, int height, int[] pixels)Wraps existing pixels.
Parameters
xint- left edge
yint- top edge
widthint- width
heightint- height
pixelsint[]width * heightpixels, row major; null for transparent
Method details
getX
public int getX()Left edge.
getY
public int getY()Top edge.
getWidth
public int getWidth()Width in pixels.
getHeight
public int getHeight()Height in pixels.
getPixels
public int[] getPixels()The pixel array, row major. Changes write through.
get
public int get(int px, int py)The pixel at absolute coordinates, transparent outside.
Parameters
pxint- absolute x
pyint- absolute y
copy
public Raster copy()A deep copy.
isEmpty
public boolean isEmpty()True when every pixel is fully transparent.
resize
public Raster resize(int nx, int ny, int nw, int nh)Returns a raster covering
[nx, ny, nw, nh] with this one’s pixels copied in.Parameters
nxint- new left edge
nyint- new top edge
nwint- new width
nhint- new height
composite
public void composite(Raster src, BlendMode mode, float opacity)Composites
src onto this raster where they overlap.Parameters
srcRaster- the layer
modeBlendMode- how colors combine
opacityfloat- the layer’s opacity, 0 to 1
applyMask
public void applyMask(byte[] mask)Multiplies each pixel’s alpha by a coverage mask of the same geometry (0..255).
Parameters
maskbyte[]- one byte of coverage per pixel
transform
public Raster transform(Matrix m, int[] clip)Returns this raster drawn through a transform, sampled bilinearly, clipped to the
device rectangle
clip (x, y, w, h) when it is not null.Parameters
mMatrix- maps this raster’s absolute coordinates to device coordinates
clipint[]- limits the result; may be null