Created
April 7, 2018 10:11
-
-
Save pauldendulk/bceb790607660471b2b674e92721504a to your computer and use it in GitHub Desktop.
GetSkiaScale
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private float GetSkiaScale() | |
{ | |
var presentationSource = PresentationSource.FromVisual(this); | |
if (presentationSource == null) throw new Exception("PresentationSource is null"); | |
var compositionTarget = presentationSource.CompositionTarget; | |
if (compositionTarget == null) throw new Exception("CompositionTarget is null"); | |
var m = compositionTarget.TransformToDevice; | |
var dpiX = m.M11; | |
var dpiY = m.M22; | |
if (dpiX != dpiY) | |
throw new ArgumentException(); | |
return (float)dpiX; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment