HiDPI show wrong size of picture

I have build some apps also for Linux systems. Now I have converted all images to HiDPI. The pictures looks good on Mac and Windows, but not on Linux systems (without HiDPI display). It shows always the big picture in double size.

Example:
Good:

Wrong:

Tested on RedHat Linux 7

Did you have HiDPI selected when you built for Linux?

In the shared build settings “Supports HiDPI” is on. The toolbar icons are okay. The problem is on a canvas with property “background = myImage”. Also I use on the paint event of a canvas this:
Sub Paint(g As Graphics, areas() As REALbasic.Rect) Handles Paint
g.DrawPicture(RedHatLogo128,0,0)
End Sub

It’s the same problem. It shows the wrong picture size.

What about using #If TargetLinux followed by the use of the standard (72 dpi) image ?

[quote=315877:@Horst Jehle]In the shared build settings “Supports HiDPI” is on. The toolbar icons are okay. The problem is on a canvas with property “background = myImage”. Also I use on the paint event of a canvas this:
Sub Paint(g As Graphics, areas() As REALbasic.Rect) Handles Paint
g.DrawPicture(RedHatLogo128,0,0)
End Sub

It’s the same problem. It shows the wrong picture size.[/quote]
Questions:

What’s the value of g.scalex and g.scaley?

Assign RedHatLogo128 to a picture property and check the horizontal and vertical resolutions.

Both images has 72 DPI.

My application is build for Windows and Linux. On Windows platform the picture is correct drawn, only on Linux (RedHat or Ubuntu) the picture are drawn with the wrong size.

Now I have made a new application with the same pictures. The new complied Linux 64 Bit application looks good. The picture has the same size. I have checked this with a compiled version one made on a Mac and the other one made on Windows. I got the same result. All pictures a drawn correct.

I have deleted the pictures in my old project and made a new picture with the same graphics files. After I have compiled my app for Linux, I got the same wrong picture size.

After I have cleared the application cache, removed the complete build folder and compiled the app, I got the same image problem. When I check the folder “Resources”, the image with the double size was renamed to “RedHat128@2x.png” and the normal size has the same name "RedHat128.png. But when I check the resolution for both pictures, I got 96 x 96 DPI.

Also I have checked my new Linux Test App. On mac the images in the resources folder has the same resolution of 72 x72 DPI. On Windows they have 96 x 96 DPI.

AFAIK (and I can be wrong), the resolution (dpi) of the two files cannot be the same / the size (width / height) have to be the same.

My advice:

take your orginal file and:

set the @2x image to 144dpi set the “@1x” image to 72dpi

Both images have the same x, y values.

Replace the current image by these new ones and run.

When you know, it is not really easy to explain these things. And once you know… things are not easy to explain too, so one can share bad / wrong / not completely true… explanaton. :frowning:

The problem (to understand) lies in the fact Photoshop (by example, but not only) propose by default to “display all pixels” even if the Pixels are <> from Points: the image appears two (or more) times larger than the “display points” settings. Note that I do not have used Photoshop since… ages, so the names can be different.

About 72 and 96 dpi: these are the default resolution (in dpi) for each OS (72: macOS; 96: Windows).
When ou open a 96dpi image in Preview, make a copy / newand compare the results: one image will be “larger” than the other. With Copy / Paste / New, Preview does not always know / support/ respect the original resolution (72 /96 / 144…).

Another simple test you can do is on macOS: take a non 72 dpi image , open a window, open the “Show the presentation options” (translated from French, so the english sentence can be a bit different), click in the Image --> Background and drop that image into the graphic area.
The Finder will display the image accordingly to its dpi: smaller or larger of the standard size (72 dpi) depending on its real dpi value.

Hi Emile, thanks for your answer.

In all my project I use images with 72 x 72 DPI for @1 and @2 pictures. This works on macOS, (with and without Retina Display), iOS, Windows and Linux. When I compile my apps on my Mac all images in the resources folder for all applications have the same resolution of 72 x 72 DPI for each size @1 and @2. When I compile these apps with Xojo on an Window machine, I got the problem that all pictures have 96 x 96 DPI in the resources folder of the compiled Linux app folder. I think this is a bug in the windows release of Xojo 2016 R4.1

[quote=316032:@Horst Jehle]Both images has 72 DPI.

My application is build for Windows and Linux. On Windows platform the picture is correct drawn, only on Linux (RedHat or Ubuntu) the picture are drawn with the wrong size.[/quote]
Please check the values from inside your paint event. The Graphics object has both ScaleX and ScaleY properties and I’d like to know if the Xojo Framework has changed the resolution of those images at runtime.

The picture size on runtime shows also 72 x 72 DPI. But you can seen in the screenshot the picture is too big (creater than 128 pixel). When I replace the pictures in the resources folder with the original pictures (with 72 DPI) an restart the application the image is drawn perfect.

Example: Image is greater than 128 pixel, but resolution shows always 72 DPI

Example: replace images in the resources folder

Do you use imagesets or are you manually assigning different images?

I tried to duplicate the issue with a simple app, built on Mac and Windows for Linux 64Bit, but I cannot – everything looks good. Could you send a link to a demo project of yours where this problem occurs?

The problem exists only if you use HiDPI pictures in your project and build you app for Linux on Windows platform. If I use same project with the same pictures on macOS to build my app for Linux, there is no problem.

I give up. If you think there’s a bug, file a report in Feedback with a reproducible example project and we’ll get it looked at.

Horst:

the two images have to have the same width and height, but different DPI.

What you say you have now is two images with different width and height and same DPI and this is wrong.

This is the current status:
Original image file no. 1:
RedHat128 (128 x 128 pixel and 72 x 72 dpi)

Original image file no. 2:
RedHat256 (256 x 256 pixel and 72 x 72 dpi)

Create an image-set in Xojo and drop image no. 1 into @1 and drop image no. 2 into @2

Add a canvas to window1, select RedHat128 from then pop-up menu. Build it on Windows platform for Linux 64 bit. After this all images in the applications resources folders have 96 x 96 dpi. Also the the images for @1.

If you build this app on macOS for Linux 64 Bit. All images has 72 x 72 dpi and the application shows the correct images.

If I add a toolbar to window1, all images 32 x 32 pixel for @1 (and 64 x 64 pixel for @2) are drawn correct in the app, when i build this on a Windows machine for Linux 64 bit. But the images for the toolbar in the applications resources folder has 96 x 96 dpi.

This is where the application troubles are:

Original image file no. 2: RedHat256 (256 x 256 pixel and 72 x 72 dpi)

The real value have to be:

Original image file no. 2: RedHat256 (128 x 128 pixel and 144 x 144 dpi)

If you do not know how to generate such an image, just ask.

About 96 x 96: beside the value is not what you’ve done, does it hurts the program ?
If not, just forget about it.

Edit:
A good question is… How do you get the 256 x 256 image (Original image file no. 2) ?

When I create a picture with 128 x 128 pixel and 144 x 144 dpi, I got a warning in the IDE:
“Current image is 128 x 128 @ 144 ppi and will be scaled”

When I build the app with this picture on Windows platform for 64 Bit Linux, I got the same wrong result. The picture fits not in the canvas area.