Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class Compositor

  1. Object
  2. Compositor

Software compositing of ARGB pixel arrays.

Uses the formulas of the W3C Compositing and Blending specification: the blended color is mixed with the layer’s color by the backdrop’s alpha, then composited source-over. Pixels are non-premultiplied 0xAARRGGBB ints, as Image.getRGB returns them.

Fields

public static final int SCRATCH = 18The scratch space blend(int, int, BlendMode, float, double[]) needs, in doubles.

Methods

public static void composite(int[] src, int[] dst, BlendMode mode, float opacity)Composites src over dst in place.
public static int blend(int src, int dst, BlendMode mode, float opacity)Composites one pixel and returns the result.
public static int blend(int src, int dst, BlendMode mode, float opacity, double[] scratch)Blends one pixel without allocating, for loops over many pixels.

Inherited methods

Field details

SCRATCH

public static final int SCRATCH = 18
The scratch space blend(int, int, BlendMode, float, double[]) needs, in doubles.

Method details

composite

public static void composite(int[] src, int[] dst, BlendMode mode, float opacity)
Composites src over dst in place.

Parameters

src int[]
the layer’s pixels
dst int[]
the backdrop, overwritten with the result; same length as src
mode BlendMode
how colors combine
opacity float
the layer’s opacity, 0 to 1, applied on top of each pixel’s own alpha

blend

public static int blend(int src, int dst, BlendMode mode, float opacity)
Composites one pixel and returns the result.

Parameters

src int
the layer’s pixel
dst int
the backdrop pixel
mode BlendMode
how colors combine
opacity float
the layer’s opacity, 0 to 1

blend

public static int blend(int src, int dst, BlendMode mode, float opacity, double[] scratch)
Blends one pixel without allocating, for loops over many pixels.

Parameters

src int
the layer’s pixel
dst int
the backdrop pixel
mode BlendMode
how colors combine
opacity float
the layer’s opacity, 0 to 1
scratch double[]
at least SCRATCH doubles, reused across calls

Returns

the composited pixel