0

How to get scaled resolution (480 × 800 or 480 × 853) from devices on Windows Phone 8.1? I have some phones for tests:

  • resolution - 480 x 800 - layout - 400 x 666
  • resolution - 720 x 1280 - layout - 514 x 914
  • resolution - 1080 x 1920 - layout - 490 x 872
TwentySix
  • 61
  • 4

1 Answers1

0

you can use

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

ResolutionScale will give you scale factor : 1. ResolutionScale.Scale100Percent: 2. ResolutionScale.Scale140Percent: 3. ResolutionScale.Scale180Percent:

Go through below useful links for more clarity:

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

EDIT:

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
}
Nishi
  • 614
  • 4
  • 18
  • It's returns strange values. On my Lumia 820 with 480 x 800 real screen resolution, I get Scale140Percent, but It must be Scale100Percent (no scaling), I suppose. – TwentySix Jun 02 '15 at 17:58
  • why do you thing it should be Scale100Percent? API should be returning result as per device resolution and DPI. Another thing is for phone you should use DisplayInformation.RawPixelsPerViewPixel to detect scaling factor. I have edited my answer, go though it. – Nishi Jun 03 '15 at 06:14
  • That's works but it's not very flexible. Because I'm not getting 'scaled resolution' needed for other calculations. – TwentySix Jun 04 '15 at 12:55
  • There is no API to get the scaled resolution. You can get the scaling percent or raw pixel value. May be you need to change your as per available support. What exactly is your requirement after getting scaled resolution? – Nishi Jun 04 '15 at 16:39
  • check this link if helpful http://blogs.msdn.com/b/b8/archive/2012/03/21/scaling-to-different-screens.aspx – Nishi Jun 04 '15 at 16:59
  • All design layouts made in resolution of 480 x 800 / 853. And some elements have a fixed size (for example 80 px). I would like to create function that receive design layout sizes or coordinates, and returns value based on current screen size. it will help keep the proportions. – TwentySix Jun 04 '15 at 18:28