var Form1: TForm1; FilePos:Integer; //用来记录文件位置 implementation uses jpeg;//使Image能显示jpg文件 {$R *.dfm} {**你可以用一个TFileListBox来作。指定好它的目录,它就会自**} {**动抓出这个目录下这所有文件,设置其Mask值,过滤出图片。**}procedure TForm1.FormCreate(Sender: TObject); begin FileListBox1.Mask:='*.bmp;*.jpg'; //过滤出.bmp,.jpg文件 FileListBox1.Directory:='d:\picture\DownLoad'; FilePos:=1;//指向第一张图片文件名 end; {**用一个变量来记录文件名的TFileListBox中的位置,这样就可**} {**很容易找到下一个文件名(图片)了**************************} procedure TForm1.NextClick(Sender: TObject); begin if FileListBox1.Items.Count<0 then exit;//没有图片就退出过程 if FilePos<=FileListBox1.Items.Count then begin Image1.Picture.LoadFromFile(FileListBox1.Items.Strings[FilePos-1]); inc(FilePos); end else begin Image1.Picture.LoadFromFile(FileListBox1.Items.Strings[0]); FilePos:=2; end; end;
var jpg : TJPEGImage;
begin
bitmap:=tjpegimage.Create();
bitmap.LoadFromFile('c:\1.jpg');
Image1.Canvas.Draw(0, 0, Bitmap);
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var jpg : TJPEGImage;
begin
jpg:=tjpegimage.Create();
jpg.LoadFromFile('c:\1.jpg');
Image1.Canvas.Draw(0, 0, jpg);
end;
Form1: TForm1;
FilePos:Integer; //用来记录文件位置
implementation
uses jpeg;//使Image能显示jpg文件
{$R *.dfm}
{**你可以用一个TFileListBox来作。指定好它的目录,它就会自**}
{**动抓出这个目录下这所有文件,设置其Mask值,过滤出图片。**}procedure TForm1.FormCreate(Sender: TObject);
begin
FileListBox1.Mask:='*.bmp;*.jpg'; //过滤出.bmp,.jpg文件
FileListBox1.Directory:='d:\picture\DownLoad';
FilePos:=1;//指向第一张图片文件名
end;
{**用一个变量来记录文件名的TFileListBox中的位置,这样就可**}
{**很容易找到下一个文件名(图片)了**************************}
procedure TForm1.NextClick(Sender: TObject);
begin
if FileListBox1.Items.Count<0 then exit;//没有图片就退出过程
if FilePos<=FileListBox1.Items.Count then
begin
Image1.Picture.LoadFromFile(FileListBox1.Items.Strings[FilePos-1]);
inc(FilePos);
end
else
begin
Image1.Picture.LoadFromFile(FileListBox1.Items.Strings[0]);
FilePos:=2;
end;
end;