Android - 将 ARGB 颜色转换为 RGB
Android - Convert ARGB Color to RGB
我正在尝试获取具有 alpha 的颜色的 rgb 值,这意味着使用不同的红色、绿色和蓝色值使其完全不透明。
例如,
Color.argb(204, 40, 40, 40) // I have this color
Color.rgb(48, 48, 48) // I expect this value
我试过将 argb 转换为 HEX,然后将 HEX 转换为 rgb,但没有用。
您输入的是半透明颜色,您希望输出稍微亮一些。这可以通过将您的输入覆盖在白色上来实现。
support-v4 库包含 ColorUtils.compositeColors
可以满足您的需要:
final int input = Color.argb(204, 40, 40, 40);
final int output = ColorUtils.compositeColors(input, Color.WHITE);
我正在尝试获取具有 alpha 的颜色的 rgb 值,这意味着使用不同的红色、绿色和蓝色值使其完全不透明。
例如,
Color.argb(204, 40, 40, 40) // I have this color
Color.rgb(48, 48, 48) // I expect this value
我试过将 argb 转换为 HEX,然后将 HEX 转换为 rgb,但没有用。
您输入的是半透明颜色,您希望输出稍微亮一些。这可以通过将您的输入覆盖在白色上来实现。
support-v4 库包含 ColorUtils.compositeColors
可以满足您的需要:
final int input = Color.argb(204, 40, 40, 40);
final int output = ColorUtils.compositeColors(input, Color.WHITE);