title: Turn off anti-aliasing for drawing to bitmap in WPF
body: <p>I rendering text to bitmap using WPF. I would like to turn off anti-aliasing, I mean I want the pixels be white or black. But the text is still blured, some pixels are even grey. </p>
  
  <p>Here is my code. Some lines are probably not needed.</p>
  
  <pre><code>RenderTargetBitmap bm = new RenderTargetBitmap(bitmapWidth, bitmapHeight, dpiX, dpiY, PixelFormats.Pbgra32);
  
  DrawingVisual drawing_visual = new DrawingVisual();
  
  RenderOptions.SetEdgeMode(drawing_visual, EdgeMode.Unspecified);            
  RenderOptions.SetBitmapScalingMode(drawing_visual, BitmapScalingMode.Linear);
  
  RenderOptions.SetEdgeMode(bm, EdgeMode.Unspecified);
  RenderOptions.SetBitmapScalingMode(bm, BitmapScalingMode.Linear);
  
  DrawingContext drawing_context = drawing_visual.RenderOpen();            
  
  FormattedText ft = new FormattedText("my text", CultureInfo.InvariantCulture, System.Windows.FlowDirection.LeftToRight, typeface, fontSize, Brushes.Black);
          drawing_context.DrawText(ft, new Point(0, 0));
  
  drawing_context.Close();
  bm.Render(drawing_visual); 
  </code></pre>
  
  <p><strong>Rendered image:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/soQ77.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/soQ77.png" alt="blured image"></a></p>
  
  <p>To check the solution, you can download source code from GitHub:</p>
  
  <pre><code>https://github.com/qub1n/Font-rendering.git
  </code></pre>