UNIT Unit17;INTERFACEUSESWinapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,Vcl.StdCtrls, Vcl.ExtDlgs, Vcl.ExtCtrls, Vcl.Imaging.jpeg; //注意:要加入jpej 否侧浏览图片时识别不到TYPETForm17 = CLASS(TForm)img1: TImage;dlgOpenPic1: TOpenPictureDialog;lbl1: TLabel;edt1: TEdit;btn1: TButton;btn2: TButton;procedure btn1Click(Sender: TObject);procedure btn2Click(Sender: TObject);PRIVATE{ Private declarations }PUBLIC{ Public declarations }END;VARForm17: TForm17;pName: STRING;IMPLEMENTATION{$R *.dfm}procedure TForm17.btn1Click(Sender: TObject);
beginif (dlgOpenPic1.Execute) thenbeginpName := dlgOpenPic1.FileName;edt1.Text := pName;img1.Picture.LoadFromFile(pName) //image的picture属性里的方法加载图片,还有loadFromStream,可以从流加加载。end;end;procedure TForm17.btn2Click(Sender: TObject);
beginclose;
end;END.