try if opendialog1.Execute then image1.Picture.LoadFromFile(opendialog1.FileName); except on EInvalidGraphic do Image1.Picture.Graphic := nil; end; Temp := Image1.Picture.Graphic is TJPEGImage; if Temp then with TJPEGImage(Image1.Picture.Graphic) do begin PixelFormat := TJPEGPixelFormat(jf24Bit); Scale := TJPEGScale(jsFullSize); Grayscale := false; Performance := TJPEGPerformance(jpBestSpeed); ProgressiveDisplay := true end; end;
这时,jpeg的代码码才进入你的.exe中,就可预览.jpg,
同样,对于.gif,也是类似(先要安装gifimage.pas),
它的头是 gifimage.hpp 但这个头跟jpeg有点不一样,加了这
个头还不行,在BCB中,还要加 #pragma link "GIFImage"
这时,gif的代码库才真正进入你的.exe,
TOpenPictureDialog也可预览了,这样 .bmp,.jpg,.gif都可以了,
在delphi处理.gif,可这样,先在Form1上放一个Image1,再调入
一幅.gif图,Run一下,停止run后删除Image1,这时,
OpenPictureDialog就可预览.gif了
我已试好了
已增加了好几百K了,这是代价
jpeg;
temp:boolean;
begin
try
if opendialog1.Execute then
image1.Picture.LoadFromFile(opendialog1.FileName);
except
on EInvalidGraphic do
Image1.Picture.Graphic := nil; end;
Temp := Image1.Picture.Graphic is TJPEGImage;
if Temp then
with TJPEGImage(Image1.Picture.Graphic) do
begin
PixelFormat := TJPEGPixelFormat(jf24Bit); Scale := TJPEGScale(jsFullSize);
Grayscale := false;
Performance := TJPEGPerformance(jpBestSpeed);
ProgressiveDisplay := true
end;
end;