Wp8.1: What about screen size and resolution?

Source: Internet
Author: User

At present, there are more and more Windows Phone devices and more sizes and resolutions on the market, especially the arrival of the wp8.1 era. People who have worked on WP development know that application adaptation is much simpler than Android. One important reason is that Microsoft claims that all WP devices will develop with two benchmark resolutions, that is, 800: 480 and 853: 480. The application adaptation of WP8 + is relatively simple, mainly to adapt the screen layout to the two ratios, presumably WVGA, wxga and 720p resolution and the corresponding simulator have a certain understanding.

The primary node has recently been stuck in the big hole of universal apps. Although the API has changed a lot, it provides more valuable information, for example, the screen's logical size, actual size, logical resolution, actual resolution, and so on. Next we will discuss the screen size and resolution of wp8.1!

First, let's take a look at the following concepts and describe the relationships and conversion methods between them.

1. Window Size

Window Size or view size. Like win8.1, wp8.1 uses window to represent the current application form. See windows. UI. XAML. Window.

We use window. bounds to obtain 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

The number of pixels per logical pixel of the current device. See windows. Graphics. display. displayinformation. logicaldpi.

// Logical Dpivar logicalDpi = DisplayInformation.GetForCurrentView().LogicalDpi;LogicalDpi.Text = logicalDpi.ToString();
3. rawpixelsperviewpixel

The actual number of pixels corresponding to each visible pixel. This is an attribute unique to wp8.1, and win8.1 is expressed using resolutionscale. See windows. Graphics. display. displayinformation. rawpixelsperviewpixel.

// RawPixelsPerViewPixelvar dpiRatio = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;RawPixelsPerViewPixel.Text = dpiRatio.ToString();
4. Scale Factor

The extension factor from the reference resolution to the actual resolution. This attribute is set to app in wp8.0. current. host. content. scalefactor: This extension factor is used to determine whether the resolution is WVGA, wxga, or 720p. The familiar 1.0, 1.6, and 1.5 rate factors are missing in wp8.1 and cannot be obtained directly. However, we can calculate them in this way,[Window. bounds. Width] * [rawpixelsperviewpixel]/480That is, we use the actual resolution and reference resolution to reverse push:

 // ScaleFactorvar scaleFactor = bounds.Width * dpiRatio /480;ScaleFactor.Text = scaleFactor.ToString();
5. Screen Resolution

Indicates the screen resolution, that is, the actual resolution. Pass[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

Indicates the logical resolution, that is, the baseline resolution. Pass[Screen Resolution]/[scale factor]To calculate:

// LogicalResolutionLogicalResolution.Text = string.Format("{0} x {1}", resolutionH/scaleFactor, resolutionW/scaleFactor);
7. Raw DPI

The actual number of points per inch on the X axis or Y axis of the screen. This value is closely related to the actual screen device and has two values respectively: rawdpix and rawdpiy:

// RawDpivar rawDpiX = DisplayInformation.GetForCurrentView().RawDpiX;var rawDpiY = DisplayInformation.GetForCurrentView().RawDpiY;RawDpi.Text = string.Format("RawDpiX:{0}, RawDpiY:{1}", rawDpiX, rawDpiY);
8. Screen Size

The size of the screen, that is, the length of the diagonal line of the actual screen, in inches. The screen size of the current device can be calculated using the preceding values. Pass[Screen Resolution]/[raw DPI]Calculate the Euclidean distance in two directions:

// ScreenInchvar screenInch = Math.Sqrt(Math.Pow(resolutionH / rawDpiY, 2) + Math.Pow(resolutionW / rawDpiX, 2));ScreenInch.Text = string.Format("{0} inches", screenInch.ToString());

 

Lab results

The primary computer conducts experiments on three simulators, namely, 8.1 WVGA 4 inch 512 8.1 m, 720 4.7 P 8.1 inch, and 1080 5.5 P inch, these three simulators are the most used simulators in wp8.1. We can get some information from the title of the simulator:

WVGA 4 inch: the screen size is 4 inch, and the WVGA resolution is 800x480. The logical and actual resolutions are the same;

720 p 4.7 inch: screen size 4.7 inch, 1280 p resolution 720x853, reference resolution 480 X;

1080 p 5.5 inch: screen size 5.5 inch, 1920 P resolution 1080x853, reference resolution 480 X.

The following are the results of these three simulators:

Pay special attention to the screen resolution, logical resolution, and screen size, which are exactly the same as we expected.

 

Summary

This article introduces the concepts and conversion methods related to the wp8.1 screen size and resolution. With these basic information, you can obtain the actual size or logical size of any element on the screen.

 

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.