启用高DPI会使TImage在运行时比设计时更小。

huangapple go评论72阅读模式
英文:

Enabling High DPI makes TImage smaller at runtime than at design-time

问题

我有一个宽度为700、高度为500的窗体。我在上面放了一个TImage,在设计时设置Align=alClientStretch=True

在运行时,图像像素变得模糊。如果我将TImage.Stretch属性设置为False,那么在运行时,图像的大小将显示为窗体大小的一半,位于左上角。每个图像在运行时都会比实际大小变小。

如果我禁用高DPI,那么一切都正常工作。

我使用Delphi Tokyo。可能的原因是什么,如何修复,以便我可以启用高DPI,而所有图像大小在运行时与设计时保持相同?

英文:

I have a Form with width 700 and height 500. I put a TImage on it, with Align=alClient and Stretch=True set at design-time.

At run-time, the Image pixels gets blurred. If I set the TImage.Stretch property to False, then at run-time the Image size is shown half of the Form size at the top-left corner. Every Image size gets smaller at run-time than its actual size.

If I disable High DPI then everything works well.

I use Delphi Tokyo. What could be the cause, and how to fix it so I can enable High DPI and all the Image size will remain the same at run-time as at design-time?

答案1

得分: 1

如果您启用了高DPI,您需要提供适当尺寸/分辨率的图像。您已经尝试过的一个选项是TImageStretch属性,但这会导致模糊显示。

正确的解决方案是使用包含适当尺寸相同图像的TImageCollection,以及用于显示的TVirtualImage控件。

不幸的是,在Delphi 10.2 Tokyo中,这两个组件都不可用,所以您要么升级到更新版本的Delphi,要么自己处理图像。

英文:

If you enable High DPI, you are responsible for providing images in the proper size/resolution. One option you already tried is the Stretch property of TImage, but that leads to a blurry display.

The correct solution is to use a TImageCollection containing the same image in appropriate sizes, and a TVirtualImage control for the display.

Unfortunately, these two components are not available in Delphi 10.2 Tokyo, so you must either upgrade to a newer version of Delphi, or take care of the image handling yourself.

huangapple
  • 本文由 发表于 2023年6月19日 23:14:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76507953.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定