1

在 XE5 中,使用 TImage,我怎样才能用他的比例尺寸拉伸位图?TImage 的宽度为 200 像素,高度为 300 像素。位图宽度为 130,高度为 80。当我将 Image1.WrapMode 设置为 iwStretch 时,位图会调整大小以适合 TImage 的区域,但不是 TImage 的比例,然后位图显示太“胖”。

非常感谢。

4

1 回答 1

0

要保持比例,您可以使用“比例”属性。例如,您在表单上加载 img (TImage) 中的图像,并使用想要缩放它的按钮,您可以这样做:

procedure THeaderFooterForm.Button5Click(Sender: TObject);
var testScale : Single;
begin
 img.WrapMode := TImageWrapMode.iwOriginal;
 testScale :=  img.Width / img.Bitmap.Width;
 if (img.Height / img.Bitmap.Height) < testScale then
    testScale := img.Height / img.Bitmap.Height;


 img.Scale.X := testScale;
 img.Scale.Y := testScale;



end;
于 2014-02-04T19:06:14.143 回答