解决方案

颜色取反 rgb COLORREF

seo靠我 2023-09-26 03:17:03

编码时遇到下面问题

背景颜色和前景颜色需要取反

COLORREF m_clr[5];

//背景颜色

 m_listPD.SetItemData(nCount,m_clr[nUltraOrder]);

//字的颜色SEO靠我取反

 m_listPD.SetItemColor(nCount,0xFFFFFF - m_clr[nUltraOrder]);  

方法即是

0xFFFFFF - $oldcolor

转自

http://zhidaSEO靠我o.baidu.com/question/143793592.html?push=ql

echo dechex(0xFFFFFF - $oldcolor);

把原文贴出来吧,不然可能不知道怎么来的。

YouSEO靠我 can invert a color by subtracting each of its red, green, and blue components from 255. In other woSEO靠我rds:

    new_red   = 255 - old_red

    new_green = 255 - old_green

    new_blue  = 255 - old_blue

You can break a coSEO靠我lor into its components, use this technique to invert the components, and then use RGB to recombine SEO靠我them into the inverted color. However, there is a much simpler method.

If a colors components are givSEO靠我en as R, G, and B, then the color is represented as:

    R + 256 * G + 256 * 256 * B

Now consider the reprSEO靠我esentation of inverse of this color with components 255 - R, 255 - G, and 255 - B:

(255 - R) + 256 * SEO靠我(255 - G) + 256 * 256 * (255 - B)

  = (255 + 256 * 255 + 256 * 256 * 255) -

(R + 256 * G + 256 * 256 * BSEO靠我)

  = &HFFFFFF - the_original_color

So a simpler method for calculating the inverse of a color is:

new_coSEO靠我lor = &HFFFFFF - old_color
“SEO靠我”的新闻页面文章、图片、音频、视频等稿件均为自媒体人、第三方机构发布或转载。如稿件涉及版权等问题,请与 我们联系删除或处理,客服邮箱:html5sh@163.com,稿件内容仅为传递更多信息之目的,不代表本网观点,亦不代表本网站赞同 其观点或证实其内容的真实性。

网站备案号:浙ICP备17034767号-2