function SaveBitmapToStream(const AStream: TStream; const Bitmap: TBitmap; const Extension: string;
SaveParams: PBitmapCodecSaveParams = nil): Boolean;
var
surf: TBitmapSurface;
begin
Result := False;
surf:= TBitmapSurface.Create;
surf.Assign(Bitmap);
try
Result := TBitmapCodecManager.SaveToStream(AStream, surf, Extension, SaveParams);
finally
surf.Free;
end;
end;
ну и вызывать типа так:
var
tmpBitmap : FMX.Graphics.TBitmap;
SaveParams : FMX.Graphics.TBitmapCodecSaveParams;
Stream : TMemoryStream;
// .....
tmpBitmap := TBitmap.Create;
// ..............
Stream := TMemoryStream.Create;
try
SaveParams.Quality := 85;
SaveBitmapToStream(Stream, tmpBitmap, '.jpg', @SaveParams);
Stream.Position := 0;
// ....................
// ....................
finally
FreeAndNil(Stream);
end;