频道分类

Delphi bmp jpg 转换保存

作者:admin 来源: 日期:2020/1/30 20:09:29 人气: 标签:

 
function BMPsaveJPGfile(bmp: TBitmap;jpgFilename:string;ACQ:integer):boolean;
Var
  jpg:TJpegImage;
  I:TBitmap;
  S,D:String;
begin
   result:=false;
  Jpg:=TJpegImage.Create;
  Jpg.Assign(bmp);
  Jpg.CompressionQuality := ACQ;
  Jpg.Compress;
  Jpg.SaveToFile(jpgFilename);
  Application.processmessages;
  Jpg.Free;
  if FileExists(jpgFilename) then
      result := True;
end;

function BMP2JPG(bmp: TBitmap;ACQ:integer):TJpegImage;
Var
  jpg:TJpegImage;
  I:TBitmap;
  S,D:String;
begin
  Jpg:=TJpegImage.Create;
  Jpg.Assign(bmp);
  Jpg.CompressionQuality := ACQ;
  Jpg.Compress;
  result:=jpg;
end;

//bmp图片转换成jpg图片
function fun_BmpToJpg(temp, path: String; ACQ: Integer): Boolean; stdcall;
var
  MyJpeg: TJpegImage;
  Bmp: TBitmap;
begin
  result := false;
  if FileExists(temp) then
  begin
    Bmp:= TBitmap.Create;
    MyJpeg:= TJpegImage.Create;
    Bmp.LoadFromFile(temp);
    MyJpeg.Assign(Bmp);
    MyJpeg.CompressionQuality := ACQ;
    MyJpeg.Compress;
    MyJpeg.SaveToFile(Path);
    MyJpeg.free;
    Bmp.free;
    if FileExists(path) then
      result := True;
  end;
end;