好的,給分吧,不過也是別人的,能用,並且還附送另一個相反的過程給你:
procedure Jpg2Bmp(JpgFile, BmpFile: String);
//將Jpg文件轉換為Bmp文件
var
MyJPEG : TJPEGImage;
MyBMP : TBitmap;
begin
MyJPEG := TJPEGImage.Create;
with MyJPEG do
try
LoadFromFile(JpgFile); //妳的圖片位置
MyBMP := TBitmap.Create;
with MyBMP do
begin
Assign(MyJPEG);
SaveToFile(BmpFile);//保存路徑
Free;
end;
finally
Free;
end;
end;
procedure Bmp2Jpg(BmpName, JpgName: String);
//將bmp文件轉換為jpg文件
var
MyJPEG : TJPEGImage;
MyBMP : TBitmap;
begin
MyBMP := TBitmap.Create;
with MyBMP do
try
LoadFromFile(BmpName); //妳的圖片位置
MyJPEG := TJPEGImage.Create;
with MyJPEG do
begin
Assign(MyBMP);
CompressionQuality:=60; //壓縮比例 1..100
Compress;
SaveToFile(JpgName);//保存路徑
Free;
end;
finally
Free;
end;
end;