Palette.Builder
class Palette.Builder
Builder class for generating Palette instances.
Summary
Public constructors |
|---|
Builder(swatches: (Mutable)List<Palette.Swatch!>) |
Public functions |
|
|---|---|
Palette.Builder |
addFilter(filter: Palette.Filter)Add a filter to be able to have fine grained control over which colors are allowed in the resulting palette. |
Palette.Builder |
Add a target profile to be generated in the palette. |
Palette.Builder |
Clear all added filters. |
Palette.Builder |
Clear any previously region set via |
Palette.Builder |
Clear all added targets. |
Palette |
generate()Generate and return the |
AsyncTask<Bitmap!, Void!, Palette!> |
This function is deprecated. Use the standard |
Palette.Builder |
maximumColorCount(colors: Int)Set the maximum number of colors to use in the quantization step when using a |
Palette.Builder |
resizeBitmapArea(area: Int)Set the resize value when using a |
Palette.Builder |
This function is deprecated. Using |
Palette.Builder |
Set a region of the bitmap to be used exclusively when calculating the palette. |
Public constructors
Public functions
addFilter
fun addFilter(filter: Palette.Filter): Palette.Builder
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. |
addTarget
fun addTarget(target: Target): Palette.Builder
Add a target profile to be generated in the palette.
You can retrieve the result via getSwatchForTarget.
clearFilters
fun clearFilters(): Palette.Builder
Clear all added filters. This includes any default filters added automatically by Palette.
clearRegion
fun clearRegion(): Palette.Builder
Clear any previously region set via setRegion.
clearTargets
fun clearTargets(): Palette.Builder
Clear all added targets. This includes any default targets added automatically by Palette.
generate
fungenerate(listener: Palette.PaletteAsyncListener): AsyncTask<Bitmap!, Void!, Palette!>
Generate the Palette asynchronously. The provided listener's onGenerated method will be called with the palette when generated.
maximumColorCount
fun maximumColorCount(colors: Int): Palette.Builder
Set the maximum number of colors to use in the quantization step when using a android.graphics.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.
resizeBitmapArea
fun resizeBitmapArea(area: Int): Palette.Builder
Set the resize value when using a android.graphics.Bitmap as the source. If the bitmap's area is greater than the value specified, then the bitmap will be resized so that its area matches area. 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.
| Parameters | |
|---|---|
area: Int |
the number of pixels that the intermediary scaled down Bitmap should cover, or any value <= 0 to disable resizing. |
funresizeBitmapSize(maxDimension: Int): Palette.Builder
Set the resize value when using a android.graphics.Bitmap as the source. If the bitmap's largest dimension is greater than the value specified, then the bitmap will be resized so that its largest dimension matches maxDimension. If the bitmap is smaller or equal, the original is used as-is.
| Parameters | |
|---|---|
maxDimension: Int |
the number of pixels that the max dimension should be scaled down to, or any value <= 0 to disable resizing. |