0

I am using SkiaSharp in WPF to draw two lines, but the width of the lines appears to be different - the vertical line seems thicker. Is there a reason why this is happening? The version of SkiaSharp that I am using is 2.80.1.

enter image description here

<Window
    x:Class="SkiaSharpSample.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:skia="clr-namespace:SkiaSharp.Views.WPF;assembly=SkiaSharp.Views.WPF"
    Title="SkiaSharp"
    Width="525"
    Height="350"
    mc:Ignorable="d">
    <Grid>
        <skia:SKElement PaintSurface="OnPaintSurface" />
    </Grid>
</Window>

private void OnPaintSurface(object sender, SKPaintSurfaceEventArgs e)
{
    SKCanvas canvas = e.Surface.Canvas;

    // make sure the canvas is blank
    canvas.Clear(SKColors.White);

    var paint = new SKPaint
    {
        Color = new SKColor(255, 0, 0, 255),
        IsAntialias = true,
        Style = SKPaintStyle.Stroke,
        StrokeWidth = 0
    };

    canvas.DrawLine(100, 0, 100, 100, paint);
    canvas.DrawLine(100, 0, 200, 100, paint);
}
Vahid
  • 5,144
  • 13
  • 70
  • 146

1 Answers1

0

Try turning the antialiasing for the vertical line to False. I've not tested so I don't know if it will work.

rhody
  • 2,274
  • 2
  • 22
  • 40