【发布时间】:2014-11-07 07:14:54
【问题描述】:
我目前正在使用支持库 (https://developer.android.com/tools/support-library/features.html#v7-palette) 中的 Palette API
下面的代码可以很好地处理数百张图片,完全没有问题。我根据调色板结果设置文本和背景颜色。结果非常棒,而且看起来非常漂亮(如果您想在您的应用程序中重复使用它,请不要犹豫!)。
不幸的是,在数百张图片中,只有一张无法正常工作并给出奇怪的结果。 就是这个=>http://www.cineswellington.com/images/film/140929075044.jpg
由于调色板没有文档或调试模式,我真的很想知道会发生什么,以及是否有办法了解原始图片是否存在缺陷或其他什么。
Picasso.with(getActivity()).load("http://www.cineswellington.com/images/film/140929075044.jpg").into(t);
private Target t = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
public void onGenerated(Palette palette) {
((ImageView) v.findViewById(R.id.iv)).setImageDrawable(new BitmapDrawable(bitmap));
//At this point, the ImageView is correctly filled, so the bitmap object has no issue.
int textColor = palette.getLightMutedColor(android.R.color.darker_gray);
int bgColor = palette.getDarkMutedColor(android.R.color.white);
Log.d("CVE","textColorInt: "+ textColor);
Log.d("CVE","bgColorInt: "+bgColor);
Log.d("CVE","textColorHexa: "+String.format("#%06X", 0xFFFFFF & textColor));
Log.d("CVE","bgColorHexa: "+String.format("#%06X", 0xFFFFFF & bgColor));
}
});
}
};
这是输出:
textColorInt: 17170432
bgColorInt: 17170443
textColorHexa: #060000
bgColorHexa: #06000B
如果有人可以帮助我重现错误或告诉我它只发生在我身边,那就太棒了
【问题讨论】:
-
能否请您也给出正确的示例结果
-
正确的例子是用互联网上的任何图片制作的,结果是标准颜色(蓝色变化、红色、绿色等)。
标签: android android-support-library palette