wpfimageresolutiondpidpi-aware

Why does a 72 dpi image appear bigger in 96 dpi screen


  1. I set my screen to 72 DPI and designed a small png image that is 100x100 @ 72 DPI. Which means 72 pixels represents 1 inch.
  2. Now I changed my screen to 120 DPI and designed the same graphic png image with 100x100 @ 120 DPI. Which means 120 pixels represents 1 inch.
  3. Again I changed my screen to 96 DPI. Which means 96 pixels represents 1 inch. Then Created a WPF application and added the two images (step 1 and step 2) - I have set the Stretch Mode to None

Not sure if I have understood the concept properly, I expected the 72 dpi image to look smaller at 96 dpi because if 72 pixels represented 1 inch for that image, then in the new configuration 96 pixels represents 1 inch. And therefore I expected the 72 dpi image to look smaller. But is not the case. Infact, it was just he opposite. The 72 dpi image look bigger @ 96 dpi. Why? Is it like WPF will always default to 96 dpi when it comes to images?

enter image description here

Update Why is that, even at 120 dpi (setting system dpi to 120), only 96 dpi image fits 200x200 box perfectly? enter image description here


Solution

  • You are making some odd assumptions about the nature of device independent nature of WPF's graphical units.

    A device independent pixel in wpf world is worth 1/96th of an inch regardless of the screen settings. This is why only the 96 dpi experiment is correct.

    Secondly, your monitors native dpi has an impact

    The second scale factor, the “DPI setting”, is what we will vary in our tests. WPF doesn’t independently know what your monitor’s actual physical DPI value is. Instead WPF uses the current setting of this second scale factor the “DPI setting”. If the “DPI setting” does not match the true physical DPI, then WPF’s “resolution independence” will appear to break — although it really doesn’t.

    http://www.wpflearningexperience.com/?p=41