earthling
earthling

Reputation: 5264

Retrieving Windows device's DPI

Is there an API in the UWP to retrieve the device dpi? In Android there is the getDisplayMetrics().density; method. Is there an equivalent in UWP?

It looks like I'm looking for RawDPI or perhaps ScaleFactor that used to be available on the phone.

Upvotes: 3

Views: 4589

Answers (3)

Mo0gles
Mo0gles

Reputation: 10904

Adding sample how to get the DisplayInformation in C++/winrt

#include "winrt/Windows.Graphics.Display.h"

auto displayInfo = Windows::Graphics::Display::DisplayInformation::GetForCurrentView();

Upvotes: 0

Emil
Emil

Reputation: 6903

in Addition to correct answer. There is even more than that you can get actual screen size using.

 DisplayInformation.GetForCurrentView().DiagonalSizeInInches;

Upvotes: 2

earthling
earthling

Reputation: 5264

Found it here after a bit of digging:

Windows.Graphics.Display.DisplayInformation

Lots of good stuff available include raw dpi and scale factor.

Upvotes: 6

Related Questions