BMP2JPG,JPG2BMP

BMP2JPG,JPG2BMP

代码

// uses jpeg
procedure BMP2JPG( const BMPFile: string );
var
BMP: TBitmap;
JPG: TJpegImage;
FileName:
string ;
begin
FileName :
= BMPFile;
BMP :
= TBitmap.Create;
JPG :
= TJpegImage.Create;
try
BMP.LoadFromFile(FileName);
JPG.Assign(BMP);
FileName :
= ChangeFileExt(FileName, ' .jpg ' );
JPG.SaveToFile(FileName);
finally
BMP.Free;
JPG.Free;
end ;
end ;

procedure JPG2BMP( const JPGFile: string );
var
BMP: TBitmap;
JPG: TJpegImage;
FileName:
string ;
begin
FileName :
= JPGFile;
BMP :
= TBitmap.Create;
JPG :
= TJpegImage.Create;
try
JPG.LoadFromFile(FileName);
BMP.Assign(JPG);
FileName :
= ChangeFileExt(FileName, ' .bmp ' );
BMP.SaveToFile(FileName);
finally
BMP.Free;
JPG.Free;
end ;
end ;

 

转载于:https://www.cnblogs.com/Jekhn/archive/2010/12/28/1918713.html

你可能感兴趣的:(BMP2JPG,JPG2BMP)