如何在Windows Phone 8.1上获得缩放分辨率

时间:2015-06-01 19:08:47

标签: windows-phone windows-phone-8.1

如何从Windows Phone 8.1上的设备获得缩放分辨率(480×800或480×853)?我有一些测试手机:

  • 分辨率 - 480 x 800 - 布局 - 400 x 666
  • 分辨率 - 720 x 1280 - 布局 - 514 x 914
  • 分辨率 - 1080 x 1920 - 布局 - 490 x 872

1 个答案:

答案 0 :(得分:0)

你可以使用

    DisplayInformation di = DisplayInformation.GetForCurrentView();
    ResolutionScale rs = di.ResolutionScale;

ResolutionScale将为您提供比例因子: 1. ResolutionScale.Scale100Percent: 2. ResolutionScale.Scale140Percent: 3. ResolutionScale.Scale180Percent:

通过以下有用链接以获得更清晰:

https://invokeit.wordpress.com/2014/10/08/images-and-scaling-with-windows-runtime-winrt-wpdev-windev/

http://channel9.msdn.com/Events/Build/2014/3-541

修改

var rawpixelperview = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel; 

var Width = Convert.ToInt32(Window.Current.Bounds.Width * rawpixelperview); 
var Height = Convert.ToInt32(Window.Current.Bounds.Height * rawpixelperview); 

if(Width == 480 && Height == 800)
{
    // logic here for this scale
}
else if((Width == 720 && Height == 1280 ) || (Width == 768 && Height == 1280))
{
     // logic here for this scale
}
else
{
     // logic here for this scale
}