Allow Anti-Aliasing to be disabled
See original GitHub issueIs your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I’m always frustrated when […]
Drawing 1-pixel thick lines results in blurry, fuzzy outputs while using DrawingContext.DrawLine().
 I believe this is due to anti-aliasing.
I believe this is due to anti-aliasing.
Describe the solution you’d like A clear and concise description of what you want to happen.
A way to disable anti-aliasing for the drawing context (which I believe is included in native WPF).
Describe alternatives you’ve considered A clear and concise description of any alternative solutions or features you’ve considered.
Right now, I can add 0.5 to all my x,y values to prevent this behavior.

But this is less than ideal as I can’t add a centre line through the square without it being blurred.
Additional context Add any other context or screenshots about the feature request here.
Blurry lines:
public void Draw(double x, double y, DrawingContext drawingContext)
{
    Pen _pen = new(new SolidColorBrush(Color.FromRgb(202, 205, 169)));
    List<Point> Points = new List<Point>()
    {
        new Point(x - 4, y - 4),
        new Point(x + 4, y - 4),
        new Point(x + 4, y + 4),
        new Point(x - 4, y + 4),
        new Point(x - 4, y - 4),
    };
    for (int i = 0; i < Points.Count - 1; i++)
    {
        drawingContext.DrawLine(_pen, Points[i], Points[i + 1]);
    }
}
Non-blurry lines:
public void Draw(double x, double y, DrawingContext drawingContext)
{
    Pen _pen = new(new SolidColorBrush(Color.FromRgb(202, 205, 169)));
    List<Point> Points = new List<Point>()
    {
        new Point(x - 4.5, y - 4.5),
        new Point(x + 4.5, y - 4.5),
        new Point(x + 4.5, y + 4.5),
        new Point(x - 4.5, y + 4.5),
        new Point(x - 4.5, y - 4.5),
    };
    for (int i = 0; i < Points.Count - 1; i++)
    {
        drawingContext.DrawLine(_pen, Points[i], Points[i + 1]);
    }
}
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (2 by maintainers)

 Top Related Medium Post
Top Related Medium Post Top Related StackOverflow Question
Top Related StackOverflow Question
@kolbyd @HoneyTauOverTwo you can set RenderOptions.BitmapInterpolationMode property:
It has quite confusing naming for enum values, because we copied Skia naming. https://github.com/AvaloniaUI/Avalonia/blob/d1afd3bb591c266015dcdecc9611148ca08c2ee4/src/Skia/Avalonia.Skia/SkiaSharpExtensions.cs#L16 https://github.com/AvaloniaUI/Avalonia/blob/4c77f1eb3d11308412b915a82460e4408ce360a0/src/Windows/Avalonia.Direct2D1/Media/Imaging/WicBitmapImpl.cs#L28
@Hanprogramer If I understood correctly there is currently no easy easy to do. As you can see the issue is also still open. There is a PR to implement this, see #9584 . You may want to try this PR out and see if your issue is resolved.