TImage Stretch XE5

时间:2013-11-03 04:52:11

标签: android delphi bitmap delphi-xe5 timage

在XE5中,使用TImage,如何用比例尺寸拉伸位图? TImage的宽度为200像素,高度为300像素。并且位图具有130宽度和80高度。当我将Image1.WrapMode设置为iwStretch时,位图的大小调整为适合TImage的区域,但不是TImage的比例比例,然后位图也会显示" fat"。

非常感谢。

1 个答案:

答案 0 :(得分:0)

要保持比例,您可以使用“scale”属性。 例如,您在表单上加载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;
相关问题