BMP与JPG互换函数

function Bmp2Jpg(Bmp: TBitmap; Quality: Integer = 100): TJpegImage;
begin
  Result := nil;
  if Assigned(Bmp)
  then begin
    Result := TJpegImage.Create;
    Result.Assign(Bmp); {Its all folks...}
    Result.CompressionQuality := Quality;
    Result.JPEGNeeded; {Key method...}
    Result.Compress;
  end;
end;

function Jpg2Bmp(Jpg: TJpegImage): TBitmap;
begin
  Result := nil;
  if Assigned(Jpg)
  then begin
    Result := TBitmap.Create;
    Jpg.DIBNeeded; {Key method...}
    Result.Assign(Jpg); {Its all folks...}
  end;
end; 

你可能感兴趣的:(function,Integer)