gpt4 book ai didi

delphi - Delphi 将图片加载到图像中

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

您好,我目前正在开发一个程序,我想添加一个按钮,允许用户将计算机中的图片加载到图像中

procedure TForm1.btnLoadPicClick(Sender: TObject);
begin
img1.Picture.LoadFromFile( 'test.1');
img1.Stretch := True ;

我正在使用此代码,但它限制该人只能使用该特定图片,我希望他从他的计算机中选择一张,谢谢:)

最佳答案

您需要显示一个打开的对话框:

procedure TForm1.Button1Click(Sender: TObject);
begin
with TOpenDialog.Create(self) do
try
Caption := 'Open Image';
Options := [ofPathMustExist, ofFileMustExist];
if Execute then
Image1.Picture.LoadFromFile(FileName);
finally
Free;
end;
end;

关于delphi - Delphi 将图片加载到图像中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3865404/

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