Class Raster
java.lang.Object
com.codename1.art.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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe largest number of pixels a raster may hold: 64 megapixels. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyMask(byte[] mask) Multiplies each pixel's alpha by a coverage mask of the same geometry (0..255).voidCompositessrconto this raster where they overlap.copy()A deep copy.intget(int px, int py) The pixel at absolute coordinates, transparent outside.intHeight in pixels.int[]The pixel array, row major.intgetWidth()Width in pixels.intgetX()Left edge.intgetY()Top edge.booleanisEmpty()True when every pixel is fully transparent.resize(int nx, int ny, int nw, int nh) Returns a raster covering[nx, ny, nw, nh]with this one's pixels copied in.Returns this raster drawn through a transform, sampled bilinearly, clipped to the device rectangleclip(x, y, w, h) when it is not null.
-
Field Details
-
MAX_PIXELS
public static final int MAX_PIXELSThe largest number of pixels a raster may hold: 64 megapixels.- See Also:
-
-
Constructor Details
-
Raster
public Raster(int x, int y, int width, int height) Creates a transparent raster.
Parameters
x: left edge in device pixelsy: top edge in device pixelswidth: width, at least 0height: height, at least 0
-
Raster
public Raster(int x, int y, int width, int height, int[] pixels) Wraps existing pixels.
Parameters
x: left edgey: top edgewidth: widthheight: heightpixels: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
px: absolute xpy: absolute y
-
copy
A deep copy. -
isEmpty
public boolean isEmpty()True when every pixel is fully transparent. -
resize
Returns a raster covering
[nx, ny, nw, nh]with this one's pixels copied in.Parameters
nx: new left edgeny: new top edgenw: new widthnh: new height
-
composite
-
applyMask
public void applyMask(byte[] mask) Multiplies each pixel's alpha by a coverage mask of the same geometry (0..255).
Parameters
mask: one byte of coverage per pixel
-
transform
-