Draw text on a .net Control with negative color of the background - blend

前端 未结 2 524
天涯浪人
天涯浪人 2021-01-19 01:53

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

相关标签:
2条回答
  • 2021-01-19 02:24

    You can use XOR to calculate the negative (inverted) color;

    Public Function InvertColor(color As Long) As Long
        Return (color Xor &HFFFFFF)
    End Function
    
    0 讨论(0)
  • 2021-01-19 02:39

    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.

    0 讨论(0)
提交回复
热议问题