java.lang.Object | |
↳ | android.support.v7.graphics.Palette |
A helper class to extract prominent colors from an image.
A number of colors with different profiles are extracted from the image:
Instances can be created with the synchronous factory methods generate(Bitmap)
and
generate(Bitmap, int)
.
These should be called on a background thread, ideally the one in
which you load your images on. Sometimes that is not possible, so asynchronous factory methods
have also been provided: generateAsync(Bitmap, PaletteAsyncListener)
and
generateAsync(Bitmap, int, PaletteAsyncListener)
. These can be used as so:
Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() { public void onGenerated(Palette palette) { // Do something with colors... } });
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Palette.PaletteAsyncListener |
Listener to be used with generateAsync(Bitmap, PaletteAsyncListener) or
generateAsync(Bitmap, int, PaletteAsyncListener)
|
||||||||||
Palette.Swatch | Represents a color swatch generated from an image's palette. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Compares this instance with the specified object and indicates if they
are equal.
| |||||||||||
Generate a
Palette asynchronously.
| |||||||||||
Generate a
Palette asynchronously.
| |||||||||||
Returns a muted and dark color from the palette as an RGB packed int.
| |||||||||||
Returns a muted and dark swatch from the palette.
| |||||||||||
Returns a dark and vibrant color from the palette as an RGB packed int.
| |||||||||||
Returns a dark and vibrant swatch from the palette.
| |||||||||||
Returns a muted and light color from the palette as an RGB packed int.
| |||||||||||
Returns a muted and light swatch from the palette.
| |||||||||||
Returns a light and vibrant color from the palette as an RGB packed int.
| |||||||||||
Returns a light and vibrant swatch from the palette.
| |||||||||||
Returns a muted color from the palette as an RGB packed int.
| |||||||||||
Returns a muted swatch from the palette.
| |||||||||||
Returns all of the swatches which make up the palette.
| |||||||||||
Returns the most vibrant color in the palette as an RGB packed int.
| |||||||||||
Returns the most vibrant swatch in the palette.
| |||||||||||
Returns an integer hash code for this object.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Compares this instance with the specified object and indicates if they
are equal. In order to be equal, o
must represent the same object
as this instance using a class-specific comparison. The general contract
is that this comparison should be reflexive, symmetric, and transitive.
Also, no object reference other than null is equal to null.
The default implementation returns true
only if this ==
o
. See Writing a correct
equals
method
if you intend implementing your own equals
method.
The general contract for the equals
and hashCode()
methods is that if equals
returns true
for
any two objects, then hashCode()
must return the same value for
these objects. This means that subclasses of Object
usually
override either both methods or neither of them.
o | the object to compare this instance with. |
---|
true
if the specified object is equal to this Object
; false
otherwise.Generate a Palette
from a Bitmap
using the specified numColors
.
Good values for numColors
depend on the source image type.
For landscapes, a good values are in the range 12-16. For images which are largely made up
of people's faces then this value should be increased to 24-32.
numColors | The maximum number of colors in the generated palette. Increasing this number will increase the time needed to compute the values. |
---|
Generate a Palette
asynchronously. onGenerated(Palette)
will be called with the created instance. The resulting Palette
is the same as what
would be created by calling generate(Bitmap, int)
.
listener | Listener to be invoked when the Palette has been generated. |
---|
AsyncTask
used to asynchronously generate the instance.
Generate a Palette
asynchronously. onGenerated(Palette)
will be called with the created instance. The resulting Palette
is the same as
what would be created by calling generate(Bitmap)
.
listener | Listener to be invoked when the Palette has been generated. |
---|
AsyncTask
used to asynchronously generate the instance.
Returns a muted and dark color from the palette as an RGB packed int.
defaultColor | value to return if the swatch isn't available |
---|
Returns a muted and dark swatch from the palette. Might be null.
Returns a dark and vibrant color from the palette as an RGB packed int.
defaultColor | value to return if the swatch isn't available |
---|
Returns a dark and vibrant swatch from the palette. Might be null.
Returns a muted and light color from the palette as an RGB packed int.
defaultColor | value to return if the swatch isn't available |
---|
Returns a muted and light swatch from the palette. Might be null.
Returns a light and vibrant color from the palette as an RGB packed int.
defaultColor | value to return if the swatch isn't available |
---|
Returns a light and vibrant swatch from the palette. Might be null.
Returns a muted color from the palette as an RGB packed int.
defaultColor | value to return if the swatch isn't available |
---|
Returns the most vibrant color in the palette as an RGB packed int.
defaultColor | value to return if the swatch isn't available |
---|
Returns the most vibrant swatch in the palette. Might be null.
Returns an integer hash code for this object. By contract, any two
objects for which equals(Object)
returns true
must return
the same hash code value. This means that subclasses of Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCode
method
if you intend implementing your own hashCode
method.