WP8.1: Things about screen size and resolution

Source: Internet
Author: User

There are more and more Windows Phone devices on the market, and the size and resolution are more and more, especially the WP8.1 era. The people who have done WP development know that application adaptation is actually more simple than Android, one of the important reasons is that Microsoft is claiming that all WP devices will be 2 benchmark resolution to develop, that is, 800:480 and 853:480. wp8+ application adaptation is relatively simple, mainly to make the screen layout suitable for these two proportions, presumably to WVGA, WXGA and 720p three resolutions and corresponding simulator have a certain understanding.

The Universal has recently sunk into the big pit of apps, and although the API has changed so much that it provides more valuable information, such as the logical size of the screen, the actual size, the logical resolution, the actual resolution, and so on, let's discuss the WP8.1 screen size and resolution of those things!

Let's take a look at the following concepts and describe the relationship between them and how to convert them.

1. Window Size

Represents the window size or view size. WP8.1, like WIN8.1, uses the concept of a window to represent the currently applied form. Please see Windows.UI.Xaml.Window.

We use Window.bounds to get the size of the current window:

Window Sizevar bounds = Window.Current.Bounds; Windowsize.text = string. Format ("H {0}  x  W {1}", bounds. Height, bounds. Width);
2. Logical Dpi

Represents the number of pixels that the current device contains per logical pixel. Please see WINDOWS.GRAPHICS.DISPLAY.DISPLAYINFORMATION.LOGICALDPI.

Logical Dpivar logicaldpi = Displayinformation.getforcurrentview (). logicaldpi; Logicaldpi.text = Logicaldpi.tostring ();
3. Rawpixelsperviewpixel

Represents the actual number of pixels for each visible pixel, which is the WP8.1 unique property that WIN8.1 uses Resolutionscale to express. Please see Windows.Graphics.Display.DisplayInformation.RawPixelsPerViewPixel.

Rawpixelsperviewpixelvar dpiratio = Displayinformation.getforcurrentview (). Rawpixelsperviewpixel; Rawpixelsperviewpixel.text = Dpiratio.tostring ();
4. Scale Factor

The extension factor that represents the base resolution to the actual resolution, which is App.Current.Host.Content.ScaleFactor on WP8.0, is determined by this scaling factor to determine whether the resolution is WVGA, WXGA, or 720p. Our familiar 1.0, 1.6, and 1.5 times multiplier factors are missing on WP8.1 and cannot be obtained directly, but we can calculate this,[Window.Bounds.Width] * [Rawpixelsperviewpixel]/480, That is, we use the actual resolution and the reference resolution to reverse the push:

Scalefactorvar scalefactor = bounds. Width * dpiratio/480; Scalefactor.text = Scalefactor.tostring ();
5. Screen Resolution

Represents the screen resolution, which is the actual resolution. by [Window.Bounds.Width] * [Rawpixelsperviewpixel] and [Window.Bounds.Height] * [Rawpixelsperviewpixel] to calculate:

Screenresolutionvar Resolutionh = Math.Round (bounds. Height*dpiratio) var resolutionw = Math.Round (bounds. Width*dpiratio); Screenresolution.text = string. Format ("{0} x {1}", Resolutionh, RESOLUTIONW);
6. Logical Resolution

Represents the logical resolution, which is the baseline resolution. calculated by [screen Resolution]/[scale Factor] :

Logicalresolutionlogicalresolution.text = string. Format ("{0} x {1}", Resolutionh/scalefactor, Resolutionw/scalefactor);
7. Raw Dpi

Represents the actual number of dots per inch in the x-axis or y-axis direction of the screen, which is inseparable from the actual screen device, with Rawdpix and Rawdpiy two values, respectively:

Rawdpivar Rawdpix = Displayinformation.getforcurrentview (). Rawdpix;var Rawdpiy = Displayinformation.getforcurrentview (). Rawdpiy; Rawdpi.text = string. Format ("rawdpix:{0}, Rawdpiy:{1}", Rawdpix, Rawdpiy);
8. Screen Size

Represents the screen size, which is the length of the actual screen diagonal, in inches. With the above values, the screen size of the currently used device is fully calculated. Calculated by the Euclidean distance in the [screen Resolution]/[Raw Dpi] two directions:

Screeninchvar screeninch = math.sqrt (Math.pow (RESOLUTIONH/RAWDPIY, 2) + Math.pow (Resolutionw/rawdpix, 2)); Screeninch.text = string. Format ("{0} inches", screeninch.tostring ());

Experimental Results

The main 8.1 in three simulators, namely the WVGA 4 inch 512M, 8.1 720p 4.7 inch and 8.1 1080p 5.5 inch, these three simulators are the most used simulator on our WP8.1. Single from the simulator's title we can draw some information:

WVGA 4 inch: Screen size 4 inches, WVGA resolution 800x480, both logical and actual resolution are this value;

720p 4.7 inch: Screen size 4.7 inch, 720p resolution 1280x720, reference resolution of 853x480;

1080p 5.5 inch: Screen size 5.5 inch, 1080p resolution 1920x1080, reference resolution is 853x480.

The following are the results of these three simulators:

Pay particular attention to screen resolution, logical resolution, and screen size, exactly as we expected.

Summarize

This paper introduces the concept and conversion method of WP8.1 screen size and resolution. With these basic information, you can get the actual size or logical size of any element on the screen.

WP8.1: Things about screen size and resolution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.