HiDPI scaling and 4.0.7

Operating system : Debian Testing, Xorg with 200% scaling
wxPython version & source : 4.0.7 gtk3 (phoenix) wxWidgets 3.0.4 from debian repos
Python version & source : 3.7.5 from debian repos

Once Debian updated wxpython version to 4.0.7, i immediately realized that this issue is fixed: https://github.com/wxWidgets/Phoenix/issues/1327

I noticed it because my app started using hires assets, however, it did not scale them appropriately.

import wx


class MainFrame(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY, 'test')
        sizer = wx.BoxSizer(wx.HORIZONTAL)


        img = wx.Image('img64.png')
        scale = wx.GetApp().GetTopWindow().GetContentScaleFactor()
        print(scale)
        #img.Rescale(img.GetWidth() // int(scale), img.GetHeight() // int(scale))
        bmp = wx.StaticBitmap(self, wx.ID_ANY, img.ConvertToBitmap())
        sizer.Add(bmp, 0, wx.ALL, 0)

        self.SetSizer(sizer)
        self.Show()


app = wx.App(False)
mf = MainFrame()
app.MainLoop()

Using this image as a resource:
img64

<doing multiple posts because the board doesn’t allow me to have 2nd image in a post>

If I launch it as-is on 200% scaling (GetContentScaleFactor() reports 2.0), I end up with 128x128 bitmap:

If i uncomment the line which downscales it, I end up with loss of details (grey image).

Windows with 4.0.7.post2:

Scaling of 1.0 is reported, so by the looks of it contents of the app were upscaled by OS, and 128x128 is to be expected.

Mac OS with 4.0.7.post2:

ContentScaling is reported to be 2.0, 128x128 as well.

Now, the way which my app used to have properly scaled assets in 4.0.6 (only on Mac OS, as it is the only platform where content scaling > 1 was reported):

import wx


class MainFrame(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY, 'test')
        sizer = wx.BoxSizer(wx.HORIZONTAL)


        img = wx.Image('img64.png').ConvertToBitmap()
        scale = wx.GetApp().GetTopWindow().GetContentScaleFactor()
        print(scale)
        img.SetSize((img.GetWidth() // int(scale), img.GetHeight() // int(scale)))
        bmp = wx.StaticBitmap(self, wx.ID_ANY, img)
        sizer.Add(bmp, 0, wx.ALL, 0)

        self.SetSizer(sizer)
        self.Show()


app = wx.App(False)
mf = MainFrame()
app.MainLoop()

On mac, it results in:

Which is 64x64 image which did not lose any details.

On linux, however, the very same code results in cropped image (it is 64x64, but each image pixel is represented by 2x2 pixels on screen, with outer area of image cropped):

So, how to use hires assets properly, so that full image is shown and no details are lost, for all platforms?

Just updated to 4.1.0 and still no idea on how to use hires image resources on wxgtk. No matter what I do it seems to upscale images I use by itself. I figured I might try changing that by passing GDK_SCALE=1 GDK_DPI_SCALE=1 to my app, but then FromDIP() still doesn’t modify numbers I pass to it (and FromDIP((16, 16)) on gtk still returns 16x16).