Device-independent units in WPF

Source: Internet
Author: User

The WPF form and all internal elements are measured by device-independent units. A device irrelevant unit is defined as one of 96 points of 1 inch, that is, 1/96 inch.

Suppose we have created a WPF button in 96X96 units. If standard Windows DPI settings (96 dpi) are used ), the size of each unit is a physical pixel in the real world. The calculation formula is as follows:

Physical unit size = device independent unit size x system DPI = 1/96 inch x 96 dpi = 1 pixel

For a 20 inch-inch display with a standard resolution of 1600x1200, its screen DPI is:

(1600 ^ 2 + 1200 ^ 2) ^ 0.5/20 = 100

On such a display, a 96X96 button is smaller than 1 inch. Similarly, the DPI of 15 inch LCD display is about 85, and the buttons mentioned above are larger than 1 inch.

Now, if we set the system DPI to 120 dpi, a device-independent unit of the WPF rendering engine is equal to 1.25 pixels (1/96 inch x 120 dpi ), the actual size of a 96X96 button is 120x120 pixels.

Here we see the so-called "fractional" pixel. a drawing point may fall between two pixels of the monitor. At this time, WPF will introduce the antialias mechanism ).

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.