压缩图像文件并转换成BMP格式
2006-02-04 13:44:02 来源:WEB开发网核心提示:function GraphicToBmp(P: TPicture; Quality: Integer = 80): TBitmap;var Jpg: TJpegImage;begin Result := TBitmap.Create; with Result do begin Width := P.Widt
function GraphicToBmp(P: TPicture; Quality: Integer = 80): TBitmap;
var
Jpg: TJpegImage;
begin
Result := TBitmap.Create;
with Result do
begin
Width := P.Width;
Height := P.Height;
Canvas.Draw(0, 0, P.Graphic);
end;
if Assigned(Result) then
begin
Jpg := TJpegImage.Create;
Jpg.Assign(Result);
Jpg.ComPRessionQuality := Quality;
Jpg.JPEGNeeded;
Jpg.Compress;
if Assigned(Jpg) then
begin
Jpg.DIBNeeded;
Result.Assign(Jpg);
end;
end;
end;
var
Jpg: TJpegImage;
begin
Result := TBitmap.Create;
with Result do
begin
Width := P.Width;
Height := P.Height;
Canvas.Draw(0, 0, P.Graphic);
end;
if Assigned(Result) then
begin
Jpg := TJpegImage.Create;
Jpg.Assign(Result);
Jpg.ComPRessionQuality := Quality;
Jpg.JPEGNeeded;
Jpg.Compress;
if Assigned(Jpg) then
begin
Jpg.DIBNeeded;
Result.Assign(Jpg);
end;
end;
end;
更多精彩
赞助商链接