From 866ec0ed274b7ac5a2d34c2b4e313eb4d3b4e52b Mon Sep 17 00:00:00 2001 From: Ratish Philip Date: Tue, 10 Jan 2017 11:39:23 -0800 Subject: [PATCH] Update PageExtensions.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Taking the ScaleFactor into consideration so that the splash screen is correctly sized when used in Mobile applications. --- XamlBrewer.Uwp.AnimatedSplashScreen/PageExtensions.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/XamlBrewer.Uwp.AnimatedSplashScreen/PageExtensions.cs b/XamlBrewer.Uwp.AnimatedSplashScreen/PageExtensions.cs index 2d1b95a..7eea0e3 100644 --- a/XamlBrewer.Uwp.AnimatedSplashScreen/PageExtensions.cs +++ b/XamlBrewer.Uwp.AnimatedSplashScreen/PageExtensions.cs @@ -1,4 +1,5 @@ -using System; + +using System; using System.Numerics; using Windows.Foundation; using Windows.UI; @@ -19,6 +20,8 @@ public static class PageExtensions /// private static Page currentPage; + private static float ScaleFactor; + /// /// Opens from splash screen. /// @@ -60,6 +63,8 @@ public static void OpenFromSplashScreen(this Page page, Rect imageBounds, Uri im /// The URI of the image. public static void OpenFromSplashScreen(this Page page, Rect imageBounds, Color backgroundColor, Uri imageUri) { + ScaleFactor = (float)DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel; + page.Loaded += Page_Loaded; // Initialize the surface loader @@ -119,7 +124,7 @@ private static async void ShowImage(Page page, Rect imageBounds, Uri imageUri, C var imageSprite = compositor.CreateSpriteVisual(); imageSprite.Brush = compositor.CreateSurfaceBrush(surface); imageSprite.Offset = new Vector3((float)imageBounds.X, (float)imageBounds.Y, 0f); - imageSprite.Size = new Vector2((float)imageBounds.Width, (float)imageBounds.Height); + imageSprite.Size = new Vector2((float)imageBounds.Width / ScaleFactor, (float)imageBounds.Height / ScaleFactor); container.Children.InsertAtTop(imageSprite); }