bmp to jpg

时间:2021-06-23 09:58:50
uses Jpeg;
function BMPtoJPG(var BMPpic, JPGpic: string): boolean;
var
  Bitmap: TBitmap;
  JpegImg: TJpegImage;
begin
  result := False;
  Bitmap := TBitmap.Create;
  try
    Bitmap.LoadFromFile(BMPpic);
    JpegImg := TJpegImage.Create;
    try
      JpegImg.Assign(Bitmap);
      JpegImg.SaveToFile(JPGpic);
      result := True;
    finally
      JpegImg.Free
    end;
  finally
    Bitmap.Free
  end;
end;