Closed shivam2702 closed 7 years ago
The reason why it takes a while is that you are rotating the image on the main thread. That is not a particularly fast operation, so consider moving it to a background thread.
One other (better) option would be to use Transformer
:
photoResult
.toBitmap()
.transform(new Transformer<BitmapPhoto, Bitmap>() {
@Override
public Bitmap transform(BitmapPhoto input) {
return rotateBitmap(input.bitmap, -input.rotationDegrees);
}
})
.whenAvailable(new PendingResult.Callback<Bitmap>() {
@Override
public void onResult(Bitmap result) {
selectedBitmap = result;
stopCamera();
}
});
Thank's it saves time. but still it's taking approx 2 sec of time. Is it normal?
Yes, that is expected. Most of the time goes into decoding Bitmap
from JPEG byte array which camera sends to us. You can speed up the process by reducing the picture size in Fotoapparat initialization.
I am using version 1.3.0 Please let me know if I am doing anything wrong