[Interest] Drawing in a high DPI QImage on Windows

John Weeks john at wavemetrics.com
Fri Dec 4 02:02:32 CET 2015


We have a number of places in our code where we draw into an image (QImage, QPixmap, or a native image type) in order to improve performance.

On Macintosh, we can call QWindow::devicePixelRatio() to find a scale factor for figuring out the dimensions of the image from the size of feature we need on the screen in device-independent points.

We also need to do this on Windows. But Windows doesn't have the luxury of controlling the hardware, so the appropriate scale factor might not be 2.0 as it is on a Retina screen. In fact, we are now in possession of a Dell laptop with Windows scale factor set by default to 2.5.

Can someone show some example code or suggest API's to use for this? It appears that devicePixelRatio() will only return integer values.

We are currently building against a pretty recent build of Qt 5.6.

Thanks!
-John Weeks





More information about the Interest mailing list