Palette.Builder

public static final class Palette.Builder
extends Object

java.lang.Object
   ↳ androidx.palette.graphics.Palette.Builder


Builder class for generating Palette instances.

Summary

Public constructors

Builder(Bitmap bitmap)

Construct a new Palette.Builder using a source Bitmap

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 is deprecated. 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

Public constructors

Builder

public Builder (Bitmap bitmap)

Construct a new Palette.Builder using a source Bitmap

Parameters
bitmap Bitmap

Builder

public Builder (List<Palette.Swatch> swatches)

Construct a new Palette.Builder using a list of Palette.Swatch instances. Typically only used for testing.

Parameters
swatches List

Public methods

addFilter

public 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.

Parameters
filter Palette.Filter: filter to add.

Returns
Palette.Builder

addTarget

public Palette.Builder addTarget (Target target)

Add a target profile to be generated in the palette.

You can retrieve the result via Palette.getSwatchForTarget(Target).

Parameters
target Target

Returns
Palette.Builder

clearFilters

public Palette.Builder clearFilters ()

Clear all added filters. This includes any default filters added automatically by Palette.

Returns
Palette.Builder

clearRegion

public