gpt4 book ai didi

delphi - 显示 JPEG,调整比控件大的图像,使其恰好适合 Timage 控件边界

转载 作者:行者123 更新时间:2023-12-03 15:18:01 25 4
gpt4 key购买 nike

如果我从这样的文件加载图像 Image1.Picture.LoadFromFile(imagePath); 并且我加载的 JPEG 大于 Image1 这是一个 TImage - 如何缩放它以适合?

最佳答案

设置StretchTImage 控件的属性设置为 True

Indicates whether the image should be changed so that it exactly fits the bounds of the image control.

Set Stretch to true to cause the image to assume the size and shape of the image control. When the image control resizes, the image resizes also. Stretch resizes the height and width of the image independently. Thus, unlike a simple change in magnification, Stretch can distort the image if the image control is not the same shape as the image.

正如本文档所示,相关的替代方案是 Proportional属性。

Indicates whether the image should be changed, without distortion, so that it fits the bounds of the image control.

Set Proportional to true to ensure that the image can be fully displayed in the image control without any distortion such as occurs with the Stretch property. When Proportional is true, images that are too large to fit in the image control are scaled down (while maintaining the same aspect ratio) until they fit in the image control. Images that are too small are displayed normally. That is, Proportional can reduce the magnification of the image, but does not increase it.

When the image control resizes, the image resizes also.

关于delphi - 显示 JPEG,调整比控件大的图像,使其恰好适合 Timage 控件边界,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10075007/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com