There are many related threads in the forum but searching for retina gives too many and old results. So I ask a new question
Using older Xojo versions for a long time I switched now to the current Xojo 2017r2.1 on macOS 10.13.
After reading the DesktopHiDPISupport.pdf I got now following solution for a proper display in low and high resolution:
I created an image set containing the 1x and 2x PNG.
In the canvas I use
Sub Paint(g As Graphics, areas() As REALbasic.Rect) Handles Paint
Dim p As picture = aboutPICT.BestRepresentation(Me.Width, Me.Height, Self.ScaleFactor)
g.DrawPicture p, 0, 0, g.width, g.height, 0, 0, p.width, p.height
End Sub
(“about” is the name of the image set)
This seems to work well but I’m not sure if there is no better way
So my question is if the code above is correct or is there even a better way so that the proper image from an image set is used automatically based on the current screen resolution?
There is no need to create a separate picture object §. Just draw using a reference to your image dragged into the IDE and Xojo automajically uses the proper pic for the screen
Agreed. 3x versions are also handy in circumstances where you need to scale an image bigger than 2x. The framework would automatically use the larger image for you.
[quote=355011:@Sam Rowlands]I would suggest also, passing in the width and height of the picture.