WPF ClickOnce DPI awareness Per-Monitor v2

First of all, anyone who want’s to cry out – simply target .NET 4.6.2, per monitor DPI awareness is enabled by default – that is simply not true. What is enabled by default in .NET 4.6.2 is the boilerplate code behind the scenes – quite nasty c++ hooks in window declaration code to enable support … Read more

Pixel to Centimeter?

Similar to this question which asks about points instead of centimeters. There are 72 points per inch and there are 2.54 centimeters per inch, so just substitute 2.54 for 72 in the answer to that question. I’ll quote and correct my answer here: There are 2.54 centimeters per inch; if it is sufficient to assume … Read more

How do I convert a WPF size to physical pixels?

Transforming a known size to device pixels If your visual element is already attached to a PresentationSource (for example, it is part of a window that is visible on screen), the transform is found this way: var source = PresentationSource.FromVisual(element); Matrix transformToDevice = source.CompositionTarget.TransformToDevice; If not, use HwndSource to create a temporary hWnd: Matrix transformToDevice; … Read more

How to access screen display’s DPI settings via javascript? [duplicate]

Looks like you can use the ‘screen’ DOM object in IE, its got properties for deviceXDPI, deviceYDPI, logicalXDPI, logicalYDPI. https://www.w3schools.com/jsref/obj_screen.asp Here’s a solution from http://www.webdeveloper.com/forum/showthread.php?t=175278 (i havent tried it, seems like a total hack 🙂 Just create something 1 inch wide and measure it in pixels! console.log(document.getElementById(“dpi”).offsetHeight); #dpi { height: 1in; left: -100%; position: absolute; … Read more

Load dimension value from res/values/dimension.xml from source code

In my dimens.xml I have <dimen name=”test”>48dp</dimen> In code If I do int valueInPixels = (int) getResources().getDimension(R.dimen.test) this will return 72 which as docs state is multiplied by density of current phone (48dp x 1.5 in my case) exactly as docs state : Retrieve a dimensional for a particular resource ID. Unit conversions are based … Read more

Disable DPI awareness for WPF application

DPIAwareness Just some ideas (not tried): Are you running on XP? That option might not work on that platform. http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/5e60a54d-baf5-46e3-9eac-a959f2a0fba1/ What follows are probably just different ways to set the same DpiAwareness option: look at the “compatibility mode” settings on your EXE…right click it’s properties…and turn on “Disable display scaling” create a manifest, and say … Read more

How can I set the dpiAware property in a Windows application manifest to “per monitor” in Visual Studio?

New in Windows 10 is dpiAwareness as well as dpiAware, so we need to update this example a bit. Now, it is fine because if dpiAwareness does not exist, then the settings will be inherited from dpiAware. To enable DPI awareness in full, with the latest Win10 support (see Ref URL for other possible options), … Read more

How do I convert ppi into dpi for Android images?

Dp are Density independant pixels and are used to generalise the number of pixels a screen has. These are generalised figures taken from http://developer.android.com/guide/practices/screens_support.html xlarge screens are at least 960dp x 720dp large screens are at least 640dp x 480dp normal screens are at least 470dp x 320dp small screens are at least 426dp x … Read more