Most visited

Recently visited

Palette

public final class Palette
extends Object

java.lang.Object
    android.support.v7.graphics.Palette


辅助类从图像中提取突出的颜色。

从图像中提取许多具有不同配置文件的颜色:

These can be retrieved from the appropriate getter method.

实例使用Palette.Builder创建,支持多个选项来调整生成的调色板。 有关更多信息,请参阅该课程的文档。

代应该始终在后台线程上完成,最好是在其中加载图像的线程。 Palette.Builder支持同步和异步生成:

 // Synchronous
 Palette p = Palette.from(bitmap).generate();

 // Asynchronous
 Palette.from(bitmap).generate(new PaletteAsyncListener() {
     public void onGenerated(Palette p) {
         // Use generated instance
     }
 });
 

摘要(Summary)

Nested classes

class Palette.Builder

用于生成Palette实例的生成器类。

interface Palette.Filter

过滤器提供了一种机制,用于对产生的Palette内的哪些颜色有效进行细粒度控制。

interface Palette.PaletteAsyncListener

听众与generateAsync(Bitmap, PaletteAsyncListener)generateAsync(Bitmap, int, PaletteAsyncListener)一起使用

class Palette.Swatch

表示从图像调色板生成的色样。

公共方法(Public methods)

static Palette from(List<Palette.Swatch> swatches)

生成 Palette从预先生成的列表 Palette.Swatch样本。

static Palette.Builder from(Bitmap bitmap)

开始生成 Palette与返回 Palette.Builder实例。

static Palette generate(Bitmap bitmap, int numColors)

此方法已弃用。 使用Palette.Builder来生成调色板。

static Palette generate(Bitmap bitmap)

此方法已弃用。 使用Palette.Builder生成调色板。

static AsyncTask<BitmapVoidPalette> generateAsync(Bitmap bitmap, int numColors, Palette.PaletteAsyncListener listener)

此方法已弃用。 使用Palette.Builder生成调色板。

static AsyncTask<BitmapVoidPalette> generateAsync(Bitmap bitmap, Palette.PaletteAsyncListener listener)

此方法已弃用。 使用Palette.Builder生成调色板。

int getColorForTarget(Target target, int defaultColor)

从调色板中返回给定目标的选定颜色,作为RGB压缩整型。

int getDarkMutedColor(int defaultColor)

作为RGB压缩整数从调色板中返回静音和深色。

Palette.Swatch getDarkMutedSwatch()

从调色板中返回静音和黑色样本。

int getDarkVibrantColor(int defaultColor)

作为RGB压缩整数从调色板返回一个黑暗和鲜艳的颜色。

Palette.Swatch getDarkVibrantSwatch()

从调色板中返回一个黑暗而充满活力的色板。

int getLightMutedColor(int defaultColor)

作为RGB压缩整数从调色板中返回静音和浅色。

Palette.Swatch getLightMutedSwatch()

从调色板中返回一个静音和浅色样。

int getLightVibrantColor(int defaultColor)

作为RGB压缩整数从调色板返回一个明亮且鲜明的颜色。

Palette.Swatch getLightVibrantSwatch()

从调色板中返回一个明亮且充满活力的色板。

int getMutedColor(int defaultColor)

作为RGB压缩整数从调色板中返回一个静音颜色。

Palette.Swatch getMutedSwatch()

从调色板中返回一个静音样本。

Palette.Swatch getSwatchForTarget(Target target)

从调色板中返回给定目标的选定样本,如果 null则返回 null

List<Palette.Swatch> getSwatches()

返回组成调色板的所有色板。

List<Target> getTargets()

返回用于生成此调色板的目标。

int getVibrantColor(int defaultColor)

作为RGB压缩int返回调色板中最鲜艳的颜色。

Palette.Swatch getVibrantSwatch()

返回调色板中最生动的色板。

继承方法(Inherited methods)

From class java.lang.Object

公共方法(Public methods)

from

Palette from (List<Palette.Swatch> swatches)

生成Palette从预先生成的列表Palette.Swatch样本。 这对测试非常有用,或者您想从样本列表中重新生成Palette实例。 如果swatches为空,将返回null。

参数(Parameters)
swatches List
返回(Returns)
Palette

from

Palette.Builder from (Bitmap bitmap)

开始生成 Palette与返回 Palette.Builder实例。

参数(Parameters)
bitmap Bitmap
返回(Returns)
Palette.Builder

generate

Palette generate (Bitmap bitmap, 
                int numColors)

此方法已弃用。
使用Palette.Builder生成调色板。

参数(Parameters)
bitmap Bitmap
numColors int
返回(Returns)
Palette

generate

Palette generate (Bitmap bitmap)

此方法已弃用。
使用Palette.Builder来生成调色板。

参数(Parameters)
bitmap Bitmap
返回(Returns)
Palette

generateAsync

AsyncTask<BitmapVoidPalette> generateAsync (Bitmap bitmap, 
                int numColors, 
                Palette.PaletteAsyncListener listener)

此方法已弃用。
使用Palette.Builder生成调色板。

参数(Parameters)
bitmap Bitmap
numColors int
listener Palette.PaletteAsyncListener
返回(Returns)
AsyncTask<BitmapVoidPalette>

generateAsync

AsyncTask<BitmapVoidPalette> generateAsync (Bitmap bitmap, 
                Palette.PaletteAsyncListener listener)

此方法已弃用。
使用Palette.Builder来生成调色板。

参数(Parameters)
bitmap Bitmap
listener Palette.PaletteAsyncListener
返回(Returns)
AsyncTask<BitmapVoidPalette>

getColorForTarget

int getColorForTarget (Target target, 
                int defaultColor)

从调色板中返回给定目标的选定颜色,作为RGB压缩整型。

参数(Parameters)
target Target
defaultColor int: value to return if the swatch isn't available
返回(Returns)
int

getDarkMutedColor

int getDarkMutedColor (int defaultColor)

作为RGB压缩整数从调色板中返回静音和深色。

参数(Parameters)
defaultColor int: value to return if the swatch isn't available
返回(Returns)
int

也可以看看:

getDarkMutedSwatch

Palette.Swatch getDarkMutedSwatch ()

从调色板中返回静音和黑色样本。 可能为null。

返回(Returns)
Palette.Swatch

也可以看看:

getDarkVibrantColor

int getDarkVibrantColor (int defaultColor)

作为RGB压缩整数从调色板返回一个黑暗和鲜艳的颜色。

参数(Parameters)
defaultColor int: value to return if the swatch isn't available
返回(Returns)
int

也可以看看:

getDarkVibrantSwatch

Palette.Swatch getDarkVibrantSwatch ()

从调色板中返回一个黑暗而充满活力的色板。 可能为null。

返回(Returns)
Palette.Swatch

也可以看看:

getLightMutedColor

int getLightMutedColor (int defaultColor)

作为RGB压缩整数从调色板中返回静音和浅色。

参数(Parameters)
defaultColor int: value to return if the swatch isn't available
返回(Returns)
int

也可以看看:

getLightMutedSwatch

Palette.Swatch getLightMutedSwatch ()

从调色板中返回一个静音和浅色样。 可能为null。

返回(Returns)
Palette.Swatch

也可以看看:

getLightVibrantColor

int getLightVibrantColor (int defaultColor)

作为RGB压缩整数从调色板返回一个明亮且鲜明的颜色。

参数(Parameters)
defaultColor int: value to return if the swatch isn't available
返回(Returns)
int

也可以看看:

getLightVibrantSwatch

Palette.Swatch getLightVibrantSwatch ()

从调色板中返回一个明亮且充满活力的色板。 可能为null。

返回(Returns)
Palette.Swatch

也可以看看:

getMutedColor

int getMutedColor (int defaultColor)

作为RGB压缩整数从调色板中返回一个静音颜色。

参数(Parameters)
defaultColor int: value to return if the swatch isn't available
返回(Returns)
int

也可以看看:

getMutedSwatch

Palette.Swatch getMutedSwatch ()

从调色板中返回一个静音样本。 可能为null。

返回(Returns)
Palette.Swatch

也可以看看:

getSwatchForTarget

Palette.Swatch getSwatchForTarget (Target target)

如果 null则返回给定目标的选定样本;如果 null则返回 null

参数(Parameters)
target Target
返回(Returns)
Palette.Swatch

getSwatches

List<Palette.Swatch> getSwatches ()

返回组成调色板的所有色板。

返回(Returns)
List<Palette.Swatch>

getTargets

List<Target> getTargets ()

返回用于生成此调色板的目标。

返回(Returns)
List<Target>

getVibrantColor

int getVibrantColor (int defaultColor)

作为RGB压缩int返回调色板中最鲜艳的颜色。

参数(Parameters)
defaultColor int: value to return if the swatch isn't available
返回(Returns)
int

也可以看看:

getVibrantSwatch

Palette.Swatch getVibrantSwatch ()

返回调色板中最生动的色板。 可能为null。

返回(Returns)
Palette.Swatch

也可以看看:

Hooray!