开发者

Properly draw text on a control contrasted to it's background

开发者 https://www.devze.com 2023-04-10 10:30 出处:网络
http://fc04.deviantart.net/fs71/f/2011/277/7/6/problem_by_tekuconcept-d4btjlx.png As shown in the image above, I want to be able to draw a contrast in the string.

http://fc04.deviantart.net/fs71/f/2011/277/7/6/problem_by_tekuconcept-d4btjlx.png

As shown in the image above, I want to be able to draw a contrast in the string. I have read this link: about the same thing (technically)(http://stackoverflow.com/questions/1192543/drawing-a-contrasted-string-on-an-image/1192560#1192560) and there I found this link: talking about how to create an XOR pen/brush. I tried the GDI when drawing to a panel but when it came to initialization, I got an "...imbalanced stack detected...". Is there a way I can create this effect(without going near applying glows/outlines).

I was thinking I could draw one color to a b开发者_StackOverflow中文版itmap as well as the other the same way. Merging them, I do not currently know how to go about, and I'm not sure what affect it would have on computer performance.

(For any one curious as to what I'm doing... I'm creating a collection of custom designed controls based off the current professional GUI styles): fc09 . deviantart . net/fs71/f/2011/277/0/9/controls_by_tekuconcept-d4btji9.png


Draw the text twice using different clipping regions and different colors.


My current implementation of such a progress bar uses two bitmaps which represent two halves of the progress bar.

1) Draw a bitmap that is as wide as your current progress value.
2) Fill it with the progress bar colour.
3) Write the text in the appropriate place, as if it were in the middle of the control. It will probably cut off the right.
4) Draw a bitmap that is as wide as the rest of the progress bar.
5) Fill it with the background colour.
6) Write the text in the same place, so that it sits off the left of the image.
7) Merge the two.

It's a bit of a hack, but it works.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号