Results 1 to 3 of 3

Thread: Drawing Inverted Text

  1. #1

    Thread Starter
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Unhappy Drawing Inverted Text

    Is it possible to draw text on a Graphics object that inverts what it's drawn on?

  2. #2
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    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.

  3. #3

    Thread Starter
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    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
  •  



Click Here to Expand Forum to Full Width