不是这样的,你只要在那个例子里的uses引用 JPEG单元
uses Windows, Classes, Graphics, Forms, Controls,
FileCtrl, StdCtrls, ExtCtrls, Buttons, Spin, ComCtrls, Dialogs,jpeg;//注意最后这一个
然后在程序中做一些修改就可以了
FileExt := AnsiUpperCase(ExtractFileExt(FileListBox1.Filename));
if (FileExt = '.BMP') or (FileExt = '.ICO') or (FileExt = '.WMF') or
(FileExt = '.EMF')or (FileExt = '.JPG') then
begin
Image1.Picture.LoadFromFile(FileListBox1.Filename);
Caption := FormCaption + ExtractFilename(FileListBox1.Filename);
if (FileExt = '.BMP') or (FileExt = '.jPg')then
begin
Caption := Caption +
Format(' (%d x %d)', [Image1.Picture.Width, Image1.Picture.Height]);
ViewForm.Image1.Picture := Image1.Picture;
ViewForm.Caption := Caption;
if GlyphCheck.Checked then ViewAsGlyph(FileExt);
end
else
GlyphCheck.Checked := False;
if FileExt = '.ICO' then
begin
Icon := Image1.Picture.Icon;
ViewForm.Image1.Picture.Icon := Icon;
end;
if (FileExt = '.WMF') or (FileExt = '.EMF') then
ViewForm.Image1.Picture.Metafile := Image1.Picture.Metafile;
end;
还有一些将
FileEdit.text:=*.bmp;*.ico;*.wmf;*.emf;*.jpg;
FilterComboBox1.Filter:=Image Files (*.bmp, *.ico, *.wmf, *.emf)|*.bmp;*.ico;*.wmf;*.emf|Bitmap Files (*.bmp)|*.bmp|Icons (*.ico)|*.ico|Metafiles (*.wmf, *.emf)|*.wmf;*.emf|All files (*.*)|*.*|jpg(*.jpg)|*.jpg;
这样就可以了,你试一下吧