英文:
Enabling High DPI makes TImage smaller at runtime than at design-time
问题
我有一个宽度为700、高度为500的窗体。我在上面放了一个TImage
,在设计时设置Align=alClient
和Stretch=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,您需要提供适当尺寸/分辨率的图像。您已经尝试过的一个选项是TImage
的Stretch
属性,但这会导致模糊显示。
正确的解决方案是使用包含适当尺寸相同图像的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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论