绘制文本上的.NET控件与背景的彩色负片 - 混合负片、控件、文本、彩色

由网友(咬了月亮一口)分享简介:我想画一个进度条有个在它的中心,但我想在文本以拥有的背景负(对比)颜色 I'd like to draw a progress bar with percentage in its center, but I'd like the text to have negative (contrasted) color...

我想画一个进度条有个在它的中心, 但我想在文本以拥有的背景负(对比)颜色

I'd like to draw a progress bar with percentage in its center, but I'd like the text to have negative (contrasted) color of the background.

所以即过进度的填充部分将是白色的,而部上未填充部分将是白色的。文本的部分

So the part of the text that is over the filled portion of ProgressBar would be white and the part over unfilled portion would be white.

我可以做到这一点仅仅通过作弊

I could do this simply by "cheating"

在画的黑的文本的第一部分 在画进展矩形(它会覆盖一部分被隐藏) 在画的白色的文本在进度矩形只(裁剪吧) painting the black part of the text first painting the progress rectangle (it would cover the part to be hidden) painting the white text over the progress rectangle only (clipping it)

画文本两次对性能的影响可以忽略不计在这个应用程序,但我有兴趣,如果有一些简单的方法来做到这一点的只有两个步骤(就像有进度条莫名其妙地反转已经绘文字)与< STRONG>混合

The performance impact of painting the text twice is negligible in this application, but I'm interested if there is some simple way to do it in two steps only (like having the progress bar somehow invert the already painted text) with blending.

推荐答案

你在做什么是好的。故伎重演像SetROP2()不会再与文字得到反锯齿,尤其是ClearType的渲染工作。获取走样像素的颜色不对非常显着。 Graphics.CompositingMode相应地不支持的影响了。

What you're doing is fine. Old tricks like SetROP2() don't work anymore with text getting anti-aliased, especially with ClearType rendering. Getting the aliasing pixels with the wrong color is very noticeable. Graphics.CompositingMode accordingly doesn't support the effects anymore.

阅读全文

相关推荐

最新文章