Android APIs
public static final class

Palette.Builder

extends Object
java.lang.Object
   ↳ android.support.v7.graphics.Palette.Builder

Class Overview

Builder class for generating Palette instances.

Summary

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 generate()
Generate and return the Palette synchronously.
AsyncTask<BitmapVoidPalette> generate(Palette.PaletteAsyncListener listener)
Generate the Palette asynchronously.
Palette.Builder generator(Palette.Generator generator)
Set the Palette.Generator to use when generating the Palette.
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 resizeBitmapSize(int maxDimension)
Set the resize value when using a Bitmap as the source.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Palette.Builder (Bitmap bitmap)

Construct a new Palette.Builder using a source Bitmap

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

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

Public Methods

public Palette generate ()

Generate and return the Palette synchronously.

public AsyncTask<BitmapVoidPalette> generate (Palette.PaletteAsyncListener listener)

Generate the Palette asynchronously. The provided listener's onGenerated(Palette) method will be called with the palette when generated.

public Palette.Builder generator (Palette.Generator generator)

Set the Palette.Generator to use when generating the Palette. If this is called with null then the default generator will be used.

public Palette.Builder maximumColorCount (int colors)

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

Good values for depend on the source image type. For landscapes, good values are in the range 10-16. For images which are largely made up of people's faces then this value should be increased to ~24.

public Palette.Builder resizeBitmapSize (int maxDimension)

Set the resize value when using a Bitmap as the source. If the bitmap's largest dimension is greater than the value specified, then the bitmap will be resized so that it's largest dimension matches maxDimension. If the bitmap is smaller or equal, the original is used as-is.

This value has a large effect on the processing time. The larger the resized image is, the greater time it will take to generate the palette. The smaller the image is, the more detail is lost in the resulting image and thus less precision for color selection.