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;