Recent

Author Topic: Display scale  (Read 2705 times)

user5

  • Sr. Member
  • ****
  • Posts: 419
Display scale
« on: July 23, 2023, 02:49:36 am »
    First of all, I know that screen.width and screen.height are reduced when the display scale is increased.
For example, 1920x1080 becomes 1280x720 when the display scale is increased from 100% to 150% and
this may have something to do with the problem shown below.
    Fig. 1 shows a polygon on a TImage when the test sub-program was started with the display scale set to
100% and then increased to 150% AFTER the program was run. Everything is fine.
    However, if the display scale is set to 150% BEFORE the sub- program is run then the undesired result is
shown in Fig. 2. The image is smaller and its cropped.
    Is there something the launching application or the test sub-program can do to prevent what Fig. 2 shows?
    Of course, the launching application can detect the display scale before the test program is run and thus
alert the user if the scale is set higher than 100% but I was hoping to find a better solution.


user5

  • Sr. Member
  • ****
  • Posts: 419
Re: Display scale
« Reply #1 on: July 23, 2023, 03:58:13 am »
    I should have mentioned that the yellow crosshairs are TImages.

dseligo

  • Hero Member
  • *****
  • Posts: 1686
Re: Display scale
« Reply #2 on: July 23, 2023, 09:34:11 am »
Did you set DPI awareness in options (see attachment)?
Can you describe in more detail what is "launching application" and what is "test sub-program"?
Lazarus version and OS?

wp

  • Hero Member
  • *****
  • Posts: 13565
Re: Display scale
« Reply #3 on: July 23, 2023, 01:24:28 pm »
This issue has many faces... First of all: what do you mean with "display scale"? In windows there is the resolution settings (96ppi, 144ppi, 192 ppi, labeled as 100%, 150%, 200%) which scale all dimensions (except for bitmap images unless they are provided at different sizes, or some upscaling algorithm is employed), and there is the "text size" setting (in accessibility mode) which scales only the text.

The attached project contains a TImage which displays the Lazarus paw. And I placed two PaintBoxes over the claws in the image and painted red circles. The application is created with the default settings of Lazarus in which LCLscaling is enabled.
  • Screenshot Fig. 1 is taken from my standard working envirment: 96ppi screen resolution (or: 100% in Windows terms), and "Text size" settings unchanged at 100%. It will be taken as a reference. This is on Win-11, by the way.
  • Let's look at the "Text size" settings: Screenshot Fig. 2 still has 96 ppi screen resolution, but the "Text size" has been cranked up to 150%. The image has the same size, the circles are at their correct place, but the checkbox controls on the form overlap. That's what this setting means: increase only the text (If I would want to avoid overlapping the checkboxes I'd have to align them with the Anchor Editor). Note that this kind of scaling is not handled by LCLScaling since the screen resolution did not change.
  • In Fig. 3 the "Text size" was reset to 100%, but the screen resolution was increased to 144 ppi (150%). LCLScaling now has increased the form size, as well as the checkbox size, and even positioned the checkboxes correctly so that they do not overlap any more. But the picture is still the old size same - this is clear, because it is a bitmapped image and we did not take care of scaling. As a consequence of it, the circle markers are no longer positioned at the claws.
  • In Fig. 4, finally, we see the same situation ("text size" = 100%, screen resolution = 144ppi), but the image has been scaled by turning on its Stretch property. This works because the size of the TImage component was increased by LCLScaling. The other checkbox adjusts the line width of the circle around the claws to the higher resolution. Now we have an image which "exactly" matches the reference image, except for its magnification by the factor 1.5

user5

  • Sr. Member
  • ****
  • Posts: 419
Re: Display scale
« Reply #4 on: July 23, 2023, 02:31:24 pm »
    Yes dseligo, the DPI awareness boxes are checked. The test program will eventually be added to an existing program
that is itself launched by a main program using TProcess.  Right now I'm just working on the test program that is not
launched by anything except by me when I run it.
    The test program makes an adjustable polygon to which joint nodes can be added to create more sides to the polygon
and the joints are actually TImages that can be moved around.
    Yes wp, the scaling I refer to is on the Windows display settings page in the box under the phrase "Scale and layout".
I'm not concerned with the resolution. I understand scaling and what happens when it is increased but that is not the issue.
    The issue and the problem is WHEN the scaling is increased. If I run the test program and then increase the display scale
to 150 percent then there is no problem and the result is good without any offset adjustment made to the TImages.
    However, if I first increase the scale and THEN run the test program, the result is the unacceptable image shown in Fig. 2
of my attached images. I mentioned the main launching program because I was wondering if the main launching program
could do something to ensure that the result will be good if the scaling is increased before the test program is launched.
    Thank you for your responses.



user5

  • Sr. Member
  • ****
  • Posts: 419
Re: Display scale
« Reply #5 on: July 23, 2023, 02:58:13 pm »
    I forgot to mention that I'm using Windows 10 and the latest 32-bit version of Lazarus.
    As an experiment, I unchecked the LCL scaling box and the manifest resource checkboxes
in Project Options, increased the scale to 150 percent and then ran the test program.
    The results were good and what I wanted. I'm a little out of my league here and unsure what
to do. I assume that it's best to check both those checkboxes but if I do then the main application
will have to refuse to launch the polygon program unless the scale is at 100 percent when it's
launched. Of course, after it's launched then the scale can be increased with no problem.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Display scale
« Reply #6 on: July 23, 2023, 04:11:21 pm »
Nobody does know your test program and what you are doing inside, why not upload its source so we check and play around with it?
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

 

TinyPortal © 2005-2018