Skip to content

Commit

Permalink
Merge pull request #585 from mono/dev/fix-uwp-dpi
Browse files Browse the repository at this point in the history
Make sure to initialize the DPI field. Fixes #582
  • Loading branch information
mattleibow authored Jul 24, 2018
2 parents 8085c9f + cbbf852 commit f050094
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions source/SkiaSharp.Views/SkiaSharp.Views.UWP/SKXamlCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class SKXamlCanvas : Canvas

private IntPtr pixels;
private WriteableBitmap bitmap;
private double dpi;
private double dpi = 1;
private bool ignorePixelScaling;

public SKXamlCanvas()
Expand All @@ -28,9 +28,12 @@ private void Initialize()
if (designMode)
return;

SizeChanged += OnSizeChanged;
Unloaded += OnUnloaded;
var display = DisplayInformation.GetForCurrentView();
OnDpiChanged(display);

Loaded += OnLoaded;
Unloaded += OnUnloaded;
SizeChanged += OnSizeChanged;
}

public SKSize CanvasSize => bitmap == null ? SKSize.Empty : new SKSize(bitmap.PixelWidth, bitmap.PixelHeight);
Expand Down

0 comments on commit f050094

Please sign in to comment.