Android image cropper not returning original bitmap

63 views Asked by At

I am trying to access both cropped image as well as the original image. Using registerForActivityResult I am able to get the cropped image. I also want to access the original image. I am using only camera as cropImageOptions. I tried using method result.getOriginalBitmap() but it is not returning any bitmap. Any idea how can I access the original image after cropping is done?

My Java code of android-image-cropper:

ActivityResultLauncher<CropImageContractOptions> cropImage = registerForActivityResult(new CropImageContract(), result -> {
        if (result.isSuccessful()) {
            originalBitmap = result.getOriginalBitmap();
            croppedBitmap = BitmapFactory.decodeFile(result.getUriFilePath(getApplicationContext(), true));
            croppedImageView.setImageBitmap(croppedBitmap);
            originalImageView.setImageBitmap(originalBitmap);
        }
    });

    private void launchCropImage() {
        CropImageOptions cropImageOptions = new CropImageOptions();
        cropImageOptions.imageSourceIncludeGallery = false;
        cropImageOptions.imageSourceIncludeCamera = true;
        CropImageContractOptions cropImageContractOptions = new CropImageContractOptions(null, cropImageOptions);
        cropImage.launch(cropImageContractOptions);
    }

0

There are 0 answers