确定最明显的前景色

时间:2013-01-22 22:59:35

标签: c++ algorithm qt colors

  

可能重复:
  Good text foreground color for a given background color

在Photoshop颜色选择器中,当您选择颜色时,选择器将变为黑色或白色,具体取决于最明显的颜色(请参见图像)。他们使用什么算法,特别是,我想输入一个rgb值并返回黑色或白色。

我尝试过以下操作,虽然它有效,但它不如Photoshop那么准确。

if (color.makeGray() < 128)
    return white;
else
    return black;

enter image description here

0 个答案:

没有答案
相关问题