-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Use cropInitialCropWindowPaddingRatio
attribute and set it to 0.
Set cropFixAspectRatio
attribute to true
and cropAspectRatioX
, cropAspectRatioY
to 1
.
The resulting cropped image is always rectangular simply because bitmaps are.
Usually, the oval shape is created during rendering of the image, there are many solutions for it.
But if you do want the resulting image pixels to reflect the oval shape you can use CropImage.toOvalBitmap(Bitmap)
helper method that does exactly that.
If your main theme has NoActionBar
then you need to specify on the activity to use theme with action bar
<activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:theme="@style/Base.Theme.AppCompat" />
Make sure you call start(Context, Fragment)
overload.
Make sure you call super
if you override the onActivityResult
in the activity.
See "Using built-in Crop Image Activity".
Use pick_image_intent_chooser_title
string resource or CropImage.getPickImageChooserIntent(context, title, includeDocuments)
intent creation method.
If you request <uses-permission android:name="android.permission.CAMERA"/>
permission in the manifest then you must explicitly request Manifest.permission.CAMERA
permissions at runtime.
See "Pick image for cropping from Camera or Gallery" for sample code and this issue for more details.
You are probably using the thumbnail image.
You need to set the EXTRA_OUTPUT to a path and camera will save the full image to this path.
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Uri outputFileUri = Uri.fromFile(new File(context.getExternalCacheDir().getPath(), "pickImageResult.jpeg"));
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
Use requested size parameters to resize the cropped image to the requested size.
CropImage.activity(imageUri)
.setRequestedSize(500, 500, CropImageView.RequestSizeOptions.RESIZE_INSIDE)
.start(this);
Get the intent and start it manually:
Intent intent = CropImage.activity(imageUri)
.getIntent(getContext());
startActivityForResult(intent, myCode);
Make sure you replaced all 4 dpi variations resources (hdpi, xhdpi, xxhdpi, xxhdpi) and rebuild the project.
Your image may be too large and you are hitting max allowed texture size limitation (example question). You can limit the size of the resulting cropped image, see how-can-i-limit-the-size-of-the-cropped-image.