可绘制的Android反色 [英] Invert colors of drawable Android
本文介绍了可绘制的Android反色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能为反转的颜色在绘制对象?什么样的,你有一个负面的,你知道吗?
Is it possible to "invert" colors in a Drawable? Kind of what you have in a negative, you know?
我知道这是可能的一个绘制对象更改为黑色和白色...怎么样反相颜色?
I know it's possible to change a Drawable to black and white... what about inverting colors?
感谢您!
推荐答案
经过一番研究,我发现,解决办法是比我想象的要简单得多。
After some research I found out that solution is much simpler than I thought.
这是:
//To generate negative image
float[] colorMatrix_Negative = {
-1.0f, 0, 0, 0, 255, //red
0, -1.0f, 0, 0, 255, //green
0, 0, -1.0f, 0, 255, //blue
0, 0, 0, 1.0f, 0 //alpha
};
ColorFilter colorFilter_Negative = new ColorMatrixColorFilter(colorMatrix_Negative);
drawable.setColorFilter(colorFilter_Negative);
这篇关于可绘制的Android反色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文