Forgive me, obviously I’m still relatively new to Canvas
painting, but I was building a simple little utility on macOS to help me deal with Icon picture files, and when I ran the app on Windows, the drawing of the picture file in the Canvas came out smaller.
Oddly, on Windows, the code reports the Width
& Height
correctly (same as macOS), but the DPI on Windows says 96 whereas on macOS it it says 72 (as confirmed when I open the same file in photo editing software on both macOS & Windows).
My example is a PNG file, as are most of my Icon files.
The following is the relevant code in the Canvas Paint
event:
Dim x As Int32
Dim y As Int32
Dim w As Int32 = Self.ImageReference.Width
Dim h As Int32 = Self.ImageReference.Height
x = (Me.Width \\ 2) - (w \\ 2)
y = (Me.Height \\ 2) - (h \\ 2)
// position image in center of canvas
g.DrawPicture(Self.ImageReference, x, y)
I originally wrote the app in 2019r2.1, but I went back and made a sample app in 2019r1.1 to see if it was a bug of some kind, but I see the same (expected and unexpected) results in either version (regardless of macOS or Windows).
My sample app can be downloaded here https://basic.fyi/screenshots/ImageDPI.xojo_binary_project as well as the image you’ll see in the following screenshots.
Note: You can use the “Open…” button to load an image or just drag-and-drop the image to the Canvas.
Tested using Windows 10 Home and macOS High Sierra & Mojave.
Any advice or insight would be appreciated. Thanks.
Edited to add, ScaleFactor on all test machines is 1.0, native screen resolution.