鸿 网 互 联 www.68idc.cn

当前位置 : 服务器租用 > 编程语言开发 > delphi > >

delphi中打开图片实例demo

来源:互联网 作者:佚名 时间:2015-07-05 21:28
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.

网友评论
<