在XE5中,使用TImage,我如何使用他的比例尺寸拉伸位图?TImage的宽度为200像素,高度为300像素。位图的宽度为130,高度为80。当我将Image1.WrapMode设置为iwStretch时,将调整位图的大小以适合TImage的区域,但不是在TImage的缩放比例中,位图就会显示得太“胖”。
非常感谢。
发布于 2014-02-05 03:06:14
要保持比例,可以使用"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;https://stackoverflow.com/questions/19749950
复制相似问题