【问题标题】:Android - Convert ARGB Color to RGBAndroid - 将 ARGB 颜色转换为 RGB
【发布时间】:2017-06-29 09:57:30
【问题描述】:

我正在尝试使用 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,但不起作用。

【问题讨论】:

    标签: java android colors rgb rgba


    【解决方案1】:

    您的输入是半透明的颜色,您希望输出稍微亮一些。这可以通过将您的输入覆盖在白色上来实现。

    support-v4 库包含 ColorUtils.compositeColors,它可以满足您的需求:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      • 2013-03-13
      • 2019-02-08
      • 2015-06-02
      • 2011-07-27
      • 1970-01-01
      相关资源
      最近更新 更多