added in version 22.1.0
belongs to Maven artifact


public static final class Palette.Builder
extends Object


Builder class for generating Palette instances.


Public constructors

Palette.Builder(Bitmap bitmap)

Construct a new Palette.Builder using a source Bitmap

Palette.Builder(List<Palette.Swatch> swatches)

Construct a new Palette.Builder using a list of Palette.Swatch instances.

Public methods

Palette.Builder addFilter(Palette.Filter filter)

Add a filter to be able to have fine grained control over which colors are allowed in the resulting palette.

Palette.Builder addTarget(Target target)

Add a target profile to be generated in the palette.

Palette.Builder clearFilters()

Clear all added filters.

Palette.Builder clearRegion()

Clear any previously region set via setRegion(int, int, int, int).

Palette.Builder clearTargets()

Clear all added targets.

AsyncTask<Bitmap, Void, Palette> generate(Palette.PaletteAsyncListener listener)

Generate the Palette asynchronously.

Palette generate()

Generate and return the Palette synchronously.

Palette.Builder maximumColorCount(int colors)

Set the maximum number of colors to use in the quantization step when using a Bitmap as the source.

Palette.Builder resizeBitmapArea(int area)

Set the resize value when using a Bitmap as the source.

Palette.Builder resizeBitmapSize(int maxDimension)

This method was deprecated in API level 24.1.0. Using resizeBitmapArea(int) is preferred since it can handle abnormal aspect ratios more gracefully.

Palette.Builder setRegion(int left, int top, int right, int bottom)

Set a region of the bitmap to be used exclusively when calculating the palette.

Inherited methods

From class java.lang.Object