Picture.open get dPi

Please download the project

Img-Dpi.zip (7.1 KB)
and launch it. Drag&drop a Png (or Jpg etc.) on the Canvas or click the button and choose the picture file.

On Mac, you will not always have the good dpi displayed in Label2 (I open the same picture file with Preview to compare).
It seems that if the picture file has been saved with Xojo (and is 144 dpi), it will display 144 dpi in the label2. But if you select a file saved by another application (the Finder if you made a screencapture, or a picture saved by Preview or by Affinity), it will always display 72 dpi (even if in 144 dpi).
I launched my small program on window and all it is ok, the good dpi is displayed.

And more strange, if you drag and drop this picture

SmallRedDot@1x.zip (2.7 KB)

and drag&drop it it, Label2 will display 144 dpi. If you rename it “SmallRedDot” it will display 72 dpi???

With Xojo 2026r1.2, the macOS red dot drag result in 144 dpi.

Bug a 96 dpi .jpg file is displayed at 72,72.

That file saved at 300 dpi with Preview (and resized at 300 pixels/width gaves:

image

NB: I do not looked at the code.

I forgot: at your project launch time Xojo told me it was created with a new version AND some objects will be removed (I DO NOT KNOW ANYTHING ABOUT THAT AND I THINK I READ THE RN MORE THAN ONE TIME).

The code below returns 300 dpi as I await IN THE DEBUGGER and:
image


Var TpBckImg As New Picture(300,441)
Var TpImg as Picture
Var  TpImgW, TpImgH as Int16
Var TpCoeff as Double

Try
  TpImg = Picture.Open(f_Elt)
  Break
  TpBckImg.HorizontalResolution = 300
  TpBckImg.VerticalResolution = 300
  Break
  TpBckImg.Graphics.DrawPicture  TpImg,0,0
  Break
Catch ' @w@a@ #76011 Il faut mettre le Catch ' Impossible de lire l'image
  TpImg = Nil
End Try