根据背景颜色反转文本颜色 [英] invert text color according to background color

查看:150
本文介绍了根据背景颜色反转文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:)

我已经在Google上搜索了几个小时,但什么都没发现!

您可能还记得那些带有白色背景和蓝色(且平滑)进度指示器的WIN98/2000样式的进度条.他们的中间也显示了数字百分比.并且当进度指示器达到大约50%的数字时,位于蓝色指示器上方的数字部分将变为白色,而在白色背景上仍保持蓝色.当蓝色"越过%"符号时,整个数字现在在蓝色背景上变成白色.

我需要那种效果.我该如何在多色背景上绘制文本,而在深色背景上的文本部分则变为亮色,反之亦然.我的意思是即使这意味着要根据其下方的颜色主题将特定字符分成半亮半暗的颜色. (就像那些进度条一样)

我已经尝试过使用SetROP2模式,但是它根本不起作用.

任何帮助将不胜感激!提前致谢! :)

Hi All :)

I''ve googled this for hours but nothing came out!

You probably remember those WIN98/2000 styled progress bars that have white background and blue (and smooth) progress indicator. They also had numeric percentage shown in the middle. And when the progress indicator reaches the number arround 50% the part of the number that lies over the blue indicator becomes white, while it remains blue over the white background. And when "the blue" passes over the ''%'' symbol the entire number is now white over blue background.

I need that effect. How can I draw text over multi-colored background, and the parts of the text that lie over dark background to be bright colored and vice-versa. I mean even if that means that specific characters to be splitted half bright half dark colored according to the color theme below them. (just like those progress bars)

I''ve tried using SetROP2 mode but it didn''t work at all.

Any help will be appreciated! Thanks in advance! :)

推荐答案

将背景图像用作参考,并在内存中的背景副本上绘制文本.渲染文本后进行颜色反转.

抓住文本/背景的位图中代表您的完成百分比的部分,并将其反转,然后将其复制到屏幕上.

如果您使用的是winforms,则可以在绘画事件(基本)中完成此操作,也可以创建一个自定义控件(更多相关内容).

您将需要通过后台线程处理更新(您可以为此使用BackgroundWorker)

干杯.
Grab the background image as a reference and draw your text on a copy of the background in memory. Do the color inversion after the text is rendered.

Grab the portion of the bitmap of the text/background that represents your % complete, and invert it, then copy that to the screen.

If you are using winforms, this could be done in a paint event (basic) or you could create a custom control (a little more involved).

You''ll need to handle updates via a background thread (you could use BackgroundWorker for this)

Cheers.


这篇关于根据背景颜色反转文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆