【发布时间】:2017-08-28 12:28:49
【问题描述】:
我在 SO 上看到很多关于调整图像大小的问题/答案。
但是我找不到适合我情况的正确的。
In this post,它仅适用于您想从大图像中获得小图像的情况。
但是,如果您有一张 24x24 尺寸的图片并且您想将其调整为 256x256 尺寸,procedure 将失败并为您提供一张扭曲的图片。
下面的代码是我试图解决我的问题
Graph := TBitmap.Create;
try // After loading a .bmp file to Image1 with 48x48 dimension
Graph.Assign( Image1.Picture.Bitmap );
Graph.Canvas.StretchDraw(Rect(0, 0, 255, 255), Graph);
Graph.SetSize(255,255);
Graph.SaveToFile('Location\Resault.bmp');
finally
Graph.Free;
end;
原图:
结果(左上角黑色部分的白色方块):
我们如何将图像加载到TImage 并对其进行转换/调整大小并保存更改?
【问题讨论】:
-
使用 255x255 的临时位图并在其上拉伸小图。然后根据需要分配回
Graph。将小图像调整为大图像时,不要期望看到很好的结果。 -
@kobik 感谢您的评论,我会试一试
-
或者那个@Sami chrislema.com/…