Using images with Retina display?

69 views
Skip to first unread message

Ryan Holmes

unread,
Nov 5, 2015, 10:58:58 PM11/5/15
to wxPython-users
I develop a cross-platform program, and this is something that has bugged the users for a while. I should note that I basically inherited the program and did not develop the majority of the GUI. First, an image:


The window shown at the top was a build with wxPython 3.0, which apparently has much better Retina support for text, while the overlayed window is a build with wxPython 2.8. You can see that the text is crisp in the new version (as long as we are dealing with strictly text), but you can see that images are still blurred.

Also, please be aware that I don't actually have a Retina display and don't know how to emulate one. I'm kind of trying to patch this in the dark and hope thigns work, so that why I'm here trying to get a bit of direction

1) Is there a way to fix the blurred images? This program uses a lot of 16x16 and 24x24 png files that are sourced from 32x32 or 64x64 png files - these are loaded as images, converted to bitmaps, and then displayed. We have no control over the source of these images. Would it be sufficient to just ship with the high-quality versions and use wx.Image.Scale()? Would that fix the DPI issue?

2) The text that is still blurry (in the left-hand list, the tabs, in the gauges to the right, etc) is because this is text that is drawn onto custom widgets, which are basically bitmaps that are constructed using a MemoryDC. The initial bitmap is defined with a certain resolution, and I am not sure how to define the DPI / how to fix this (perhaps defining a large resolution and scaling down?)

Any help would be appreciated


Florian Höch

unread,
Jan 6, 2016, 5:46:10 PM1/6/16
to wxpytho...@googlegroups.com
Hi,

Am 06.11.2015 um 04:58 schrieb Ryan Holmes:
> Also, please be aware that I don't actually have a Retina display and don't know how to emulate one.

Emulation is possible but cumbersome to set up. See

http://www.tonymacx86.com/mavericks-laptop-support/133254-adding-using-hidpi-custom-resolutions.html

> 1) Is there a way to fix the blurred images? This program uses a lot of
> 16x16 and 24x24 png files that are sourced from 32x32 or 64x64 png files
> - these are loaded as images, converted to bitmaps, and then displayed.
> We have no control over the source of these images. Would it be
> sufficient to just ship with the high-quality versions and use
> wx.Image.Scale()? Would that fix the DPI issue?

Scale() will not fix the blurriness because it scales in the virtual
coordinate system (which is half the actual display resolution). I
believe wxWidgets has since had some updates that will make it use @2x
versions of the images if present, but it seems these updates are not
yet available to wxPython. I'm not sure if it's currently possible to
have crisp images on HiDPI displays using wxPython, I've not found a
solution so far.

> 2) The text that is still blurry (in the left-hand list, the tabs, in
> the gauges to the right, etc) is because this is text that is drawn onto
> custom widgets, which are basically bitmaps that are constructed using a
> MemoryDC. The initial bitmap is defined with a certain resolution, and I
> am not sure how to define the DPI / how to fix this (perhaps defining a
> large resolution and scaling down?)

I had similar problems with blurry text on custom widgets in my
application and solved it in most instances simply by using a wx.PaintDC
instead of a wx.BufferedPaintDC. Some of my widgets still need
wx.MemoryDC or other forms of buffering, so the text is still blurry there.

--
Florian Höch

Reply all
Reply to author
Forward
0 new messages