|
-
Feb 17th, 2011, 11:17 PM
#1
Thread Starter
Stack Overflow moderator
Drawing Inverted Text
Is it possible to draw text on a Graphics object that inverts what it's drawn on?
-
Feb 18th, 2011, 09:33 AM
#2
Re: Drawing Inverted Text
Here's my idea:
1.Create a colour-inverted copy of the background. See my FastPix in the CodeBank for a super-quick method if you need it.
2. Draw the text to a GraphicsPath with AddString.
3. Set the graphics clip with Graphics.SetClip(graphicspath)
4. (optional) If you want outline text, use GraphicsPath.Widen with a small pen.
5. Paint the inverted image on top of the background.
Like anything with clip regions or regions, that has the drawback that you won't get antialiased edges. If that matters, I'll need a bit more time to think of a way to solve it.
BB
Edit: later thought. If you want antialiased edges, it might work to reset the Clip, then draw the path again over the edges of the inverted part. Use Graphics.DrawPath + SmoothingMode.HighQuality, plus a pen in a neutral or partly transparent colour.
Last edited by boops boops; Feb 18th, 2011 at 10:40 AM.
-
Feb 18th, 2011, 11:08 AM
#3
Thread Starter
Stack Overflow moderator
Re: Drawing Inverted Text
That's exactly what I did the first time, but for anti-aliasing I used a TextureBrush. I want to know if there's something like the VB6 XOR drawing mode that I hear about a lot on Google.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|