//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;
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;
本文提供了一个将BMP格式图片转换为JPG格式的Delphi函数实现。该函数通过加载BMP文件到位图,然后使用JPEG图像对象进行压缩,并调整质量参数,最后保存为JPG文件。
5248

被折叠的 条评论
为什么被折叠?



