【问题标题】:Differerence between Transparent and Black background in RGBRGB中透明和黑色背景的区别
【发布时间】:2017-06-17 14:32:39
【问题描述】:

您好我有一个问题,我想知道图像的背景并确定背景是亮还是暗,问题是如果背景是暗的我想使用白色图像,如果背景是透明 我想使用黑色图标。我使用这种方法来确定背景是暗还是亮:

public static boolean isDark(float[] hsl) { // @Size(3) return hsl[2] < 0.8f; //Use 0.8f for a better precision }

问题是这种方法无法知道两种背景(深色或透明)之间的区别

【问题讨论】:

    标签: android colors background rgb


    【解决方案1】:

    您需要使用 hsla,“a”代表 alpha。这样您就可以检查背景是否透明。可能您转换为 hsl 的方法忽略了 alpha 参数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-22
      • 2012-06-26
      • 2015-07-04
      • 1970-01-01
      • 2013-11-25
      • 2015-04-20
      • 1970-01-01
      相关资源
      最近更新 更多