Yalantis / uCrop

Image Cropping Library for Android
https://yalantis.com/blog/introducing-ucrop-our-own-image-cropping-library-for-android/
11.86k stars 2.16k forks source link

reset imageUri in ucropactivity #340

Closed DancingDuck closed 7 years ago

DancingDuck commented 7 years ago

how can i reset uri image in ucropActivity ?

when i want to replace another image uri used below code! the image will scaled smaller! i just want to the original effect! private void changeImageData(Uri inputUri,Uri outputUri) { if (inputUri != null && outputUri != null) { try { mGestureCropImageView.setImageUri(inputUri, outputUri); } catch (Exception e) { setResultError(e); finish(); } } else { setResultError(new NullPointerException(getString(R.string.ucrop_error_input_data_is_absent))); finish(); } } the crop border most bigger more than image view! below is my init setting code !

    String str1 = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date());
    String str2 = "crop_" + str1 + ".jpg";
    UCrop uCrop = UCrop.of(uri, Uri.fromFile(new File(Environment.getExternalStorageDirectory(), str2)));
    UCrop.Options options = new UCrop.Options();
    options.setShowCropGrid(false);
    options.setFreeStyleCropEnabled(false);
    options.setAllowedGestures(UCropActivity.SCALE, UCropActivity.ROTATE, UCropActivity.ALL);

// uCrop.withAspectRatio(16, 9); options.setCropFrameStrokeWidth(2); options.setCompressionFormat(Bitmap.CompressFormat.JPEG); uCrop.withOptions(options); uCrop.useSourceImageAspectRatio(); uCrop.start(ShopCommentCreateActivity.this);

KucherenkoIhor commented 7 years ago

Hi, @DancingDuck. Thank you for your feedback. Did you try just to restart UCropActivity?

DancingDuck commented 7 years ago

no! just reset the image uri in the ucropactivity ! just like a menu named choose pic from photo album in the ucropactivity! you know! it,s common use1

DancingDuck commented 7 years ago

@KucherenkoIhor

DancingDuck commented 7 years ago

@KucherenkoIhor the reason that after i follow code may be reset imageURI but not reset the gestureImageview,s scale attri!

KucherenkoIhor commented 7 years ago

@DancingDuck, Please check it out!

DancingDuck commented 7 years ago

@KucherenkoIhor but i only find
mGestureCropImageView.cancelAllAnimations(); mGestureCropImageView.setImageToWrapCropBounds(); without reset scale attrib api!

KucherenkoIhor commented 7 years ago

@DancingDuck, thank you. I got you. If you have ideas how to deal with this issue, you can create a pull request. We will glad to merge it.

DancingDuck commented 7 years ago

@KucherenkoIhor i find UCropView --resetCropImageView() this can reset ! it,s okay