From ead3e95bf43190d7bf095030ebcff06650c8b692 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 14 Jan 2022 00:43:56 +0100 Subject: [PATCH] Add a note about rounding the logical pixels up when converting This might be unexpected, so explicitly warn about possibly not getting back exactly the same value after a round-trip. --- docs/doxygen/overviews/high_dpi.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/doxygen/overviews/high_dpi.md b/docs/doxygen/overviews/high_dpi.md index 2662e25dbd..5ff3362215 100644 --- a/docs/doxygen/overviews/high_dpi.md +++ b/docs/doxygen/overviews/high_dpi.md @@ -123,6 +123,16 @@ pixels first, but you can also do it directly, by using wxWindow::GetDPIScaleFactor(). This function can return a value different from 1 even under MSW, i.e. it returns DPI scaling for physical display pixels. +**Warning:** It is possible that conversion between different pixel +coordinates is not lossless due to rounding. E.g. to create a window big +enough to show a bitmap 15 pixels wide, you need to use `FromPhys(15)`, +however the exact result of this function is not representable as an `int` +when using 200% DPI scaling. In this case, the value is always rounded +upwards, i.e. the function returns `8`, to ensure that a window of this size +in logical pixels is always big enough to show the bitmap, but this can only +be done at the price of having one "extra" pixel in the window. + + Summary of Different Pixel Kinds {#high_dpi_pixel_conversions} --------------------------------