Draw pictures in a canvas with HiDPI mode

Please see sample project:
sampe project

I’m using Windows 10 with a 27" Dell HiDPI screen (3840 x 2160) with 200 % scaling.

Can anyone explain me this behaviour?
Shouldn’t the first and the second picture be the same size?
Why are the dimensions 42 x 42 if the picture is 32 x 32 (@2x = 64 x 64)?

not with this code

you never take into account the scale factor of the graphics passed to you

http://blog.xojo.com/2016/04/05/xojo-retinahidpi-the-journey-of-a-thousand-pixels/

[quote=333730:@Norman Palardy]not with this code

you never take into account the scale factor of the graphics passed to you

http://blog.xojo.com/2016/04/05/xojo-retinahidpi-the-journey-of-a-thousand-pixels/[/quote]

So how should the code look like that they are drawn the same size?
I already read the blog post and now I’m trying to make one of our projects to support HiDPI so I have to look how to solve the several issues.

Can anyone explain me this behaviour?

Look at the Image objects you created in the project. The 1x size determines the size that the image will be drawn at a HiDPI resolution. So because your ImgNoHiDPI image’s 1x representation is actually 64x64 (@72ppi) and your ImgPreview 1x picture is 32x32 (@72ppi) they draw at different sizes.

Try making the base image of ImgNoHiDPI 32x32 pixels and see if they render the same.

Unfortunately not:

So why is the ImgPreview drawn with 42 x 42 (200 % scaling)?

Interesting… macOS recognizes the 3 ImgPreview .png’s as 72DPI (Pixelmator, Affinity Photo)
However, Windows 10 (Paint, Paint.net) thinks they are 192 DPI.

I don’t know how and why this can be. But it certainly explains that Windows will handle these .png’s different to how you expect it.

And @Norman Palardy 's answer to one of your last questions applies here, too:
if you make them @ 72 DPI things should just work nicely.

And indeed: It works as expected, if I change them to 72 DPI using Paint.net on Windows 10 and save them in a way that Windows recognizes them to be 72 DPI.

I’m not really into graphics… so I’m curious to know why macOS sees these .png’s as 72 DPI, but Windows as 192 DPI.

I’ve never understood that either

Paint doesnt seem to actually read the DPI from the image itself for some reason

Photoshop says they are 72dpi:

The ImgPreview was exported with Photoshop.
If I use an image exported with Illustrator it works as expected.

If I open the exported .png files in photoshop again, change the dpi to a different value and then change it back to 72dpi and save the file it also works as expected.

So there must be some issues with the Photoshop export function … anyone any idea?

If I use the “export for screen” (don’t know how it is called exactly in english) function in Illustrator I can select my additional scaling for my images:

The problem is that Illustrator changes the dpi with the scaling (also doubles and triples the dpi).

Somehow this makes sense (or not) as it is explained in this article:
https://helpx.adobe.com/photoshop/kb/advanced-cropping-resizing-resampling-photoshop.html

Unfortunately this doesn’t work for Xojo.
How do you prepare and edit your icons for HiDPI?

EDIT: Obviously it works for Xojo with the doubled and tripled dpi.