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.
This commit is contained in:
Vadim Zeitlin
2022-01-14 00:43:56 +01:00
parent 74e1404a5a
commit ead3e95bf4

View File

@@ -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}
--------------------------------