0

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 bitmap 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

2 Answers 2

3

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

0

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.

1
  • 1
    I think I see what your saying and how I may be able to do this(maybe). Currently what I'm doing in a UserControl is on it's paint event, I draw in this order: background, bar, border, text. From what your saying, I believe I could draw the text in one color after the background then once with another color after the bar paint(using a clipping plane). Thanks, you got my wheels turning in my head again... Oct 4, 2011 at 21:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.