2

I'm using an InkCanvas in my project and I noticed that whenever I draw something, the stroke is very sharp, and once I release the mouse button it becomes blurry.

Is there any way I can keep the stroke identical to what it looks like as I'm drawing it?

Right now I'm going through the array I get from the image and I remove any pixel that doesn't perfectly match Color.Red (i.e., ARGB: 255,255,0,0)... and I'm sure there's a smarter way to do this!

Thanks in advance.

BlackRainbow
  • 105
  • 1
  • 8

1 Answers1

1

Ok. I found an answer!

Sources:

  1. https://social.msdn.microsoft.com/Forums/vstudio/en-US/d95c6b91-2a68-455b-b9d4-021bd5c96029/how-to-disable-smoothing-for-stroke-?forum=wpf
  2. Rendering sharp lines in WPF

I just tried to add RenderOptions.EdgeMode="Aliased" directly into XAML (the property doesn't show up in the Properties window, when selecting the InkCanvas) and it works. Basically from this:

<InkCanvas x:Name="myInkCanvas" MoveEnabled="False" ...>

To:

<InkCanvas x:Name="myInkCanvas" MoveEnabled="False" RenderOptions.EdgeMode = "Aliased" ...>

On MouseUp, the stroke stille "moves" a bit, but the stroke itself is perfectly sharp!

Community
  • 1
  • 1
BlackRainbow
  • 105
  • 1
  • 8