Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the advantage of device-independent pixels?

Tags:

wpf

I'm learning about WPF. WPF uses device-independent pixels. But I can't really understand them. Why are they better than device-dependent pixels, if most other apps are device-dependent and WPF apps aren't? Would they stick out?

like image 457
Karsten Avatar asked Nov 11 '10 10:11

Karsten


2 Answers

The advantage of device independent pixels is that when specifying a UI you can determine the size that UI components will appear on the user's device, regardless of the user's screen resolution. Unfortunately, it's not quite as simple as that, as it requires the user to have various settings set 'correctly', and it can be overridden by a user who wants to change the resolution of their device (e.g. a partially sighted user who wants to run at a low resolution to make text easier to read).

In addition to the other link posted, you can also check out this one:

Is WPF Really Resolution Independent?

Note that you can turn on snapping a control to device pixels with the SnapsToDevicePixels set to true to avoid the blurriness that occurs when a horizontal/vertical line is drawn on the boundary between two device pixels.

like image 171
Jackson Pope Avatar answered Nov 17 '22 23:11

Jackson Pope


Before understanding device independent unit, it is required to understand what DPI is. DPI is dots per inch, that means there would be certain number (96 usually) of pixels in an inch . But what is important to understand is in Win32 environment this inch is not fixed in size as a physical inch. So when the number of dots increases / decreases by changing the resolution there would more / less number of dots in an inch as a result the "inch" size increases or decreases. However in case of WPF the inch size is as good as a physical inch as a result every time the DPI changes the system adjusts it self accordingly.

like image 30
sumitnath Avatar answered Nov 17 '22 23:11

sumitnath