简体   繁体   English

Android - 将ARGB颜色转换为RGB

[英]Android - Convert ARGB Color to RGB

I'm trying to get the rgb value of a color with alpha, meaning make it full opaque with different red, green and blue values. 我正在尝试使用alpha获取颜色的rgb值,这意味着使用不同的红色,绿色和蓝色值使其完全不透明。

For example, 例如,

Color.argb(204, 40, 40, 40) // I have this color
Color.rgb(48, 48, 48) // I expect this value

I've tried converting argb to HEX, and after HEX to rgb, but doesn't work. 我已经尝试将argb转换为HEX,并且在HEX之后转换为rgb,但是不起作用。

Your input is a translucent color and you expect a slightly brighter output. 您的输入是半透明的颜色,您希望输出稍微亮一些。 That can be achieved by overlaying your input over white. 这可以通过将输入覆盖白色来实现。

support-v4 library contains ColorUtils.compositeColors which does what you need: support-v4库包含ColorUtils.compositeColors ,它ColorUtils.compositeColors您的需求:

final int input = Color.argb(204, 40, 40, 40);
final int output = ColorUtils.compositeColors(input, Color.WHITE);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM