unit uOpenFile;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ExtDlgs,jpeg;type TForm1 = class(TForm) btnOpenFile: TButton; image: TImage; OpenDialog: TOpenDialog; proc
unit uOpenFile;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ExtDlgs,jpeg;type TForm1 = class(TForm) btnOpenFile: TButton; image: TImage; OpenDialog: TOpenDialog; procedure btnOpenFileClick(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.btnOpenFileClick(Sender: TObject);var openPath:string;begin OpenDialog.Title := '打开图片'; OpenDialog.filter := '全部 (*.jpg;*.jpeg;*.bmp;*.ico;*.emf;*.wmf;*.png)|*.jpg;*.jpeg;*.bmp;*.i' + 'co;*.emf;*.wmf;*.png|JPEG 图像文件 (*.jpg)|*.jpg|JPEG 图像文件 (*.jpeg)|*.jpeg' + '|位图 (*.bmp)|*.bmp|图标 (*.ico)|*.ico|增强图元文件 (*.emf)|*.emf|图元文件 (*.' + 'wmf)|*.wmf|可移植图片(*.png)|*.png'; if openDialog.Execute then begin openPath:=OpenDialog.FileName; image.Picture.LoadFromFile(openPath); image.AutoSize:=False; image.Stretch:=True; end; end;end.