Cropper - NoCropper
This is a lightweight Image Cropper for Android which also supports no-crop feature.
Here's a short gif showing how it works.
And, here's a bit longer YouTube Video
CropperView
It's a FrameLayout which contains a view for Grid and an imageview. This project supports only square cropping. CropperView contains some basic methods like setImageBitmap()
, setMaxZoom()
, setMinZoom()
, etc which are forwarded to CropperImageView
.
It's not an Activity or Fragment. It's just a FrameLayout which you can use anywhere and however you want in your app. There are some styling and customizations also available.
How To Install
Maven
repositories {
maven {
url "http://dl.bintray.com/jayrambhia/maven"
}
}
JCenter
repositories {
jcenter()
}
Dependency
dependencies {
compile 'com.fenchtose.nocropper:nocropper:0.2.0'
}
CropperImageView
It's a square ImageView which acts as the cropper. It tries to keep the image in the range of max and min zoom. It automatically adjusts the position of the image, if it's zoomed out.
How To Use:
<com.fenchtose.nocropper.CropperView
android:background="#ff282828"
android:id="@+id/cropper_view"
android:layout_width="match_parent"
android:layout_height="0dp"
app:nocropper__grid_opacity="0.8"
app:nocropper__grid_thickness="0.8dp"
app:nocropper__grid_color="@color/colorAccent"
app:nocropper__padding_color="#ff282828"/>
And that's it. CropperView
is ready to be used anywhere in the app. No dependencies.
Useful Methods:
setMaxZoom(float zoom)
set Maximum zoomsetMinZoom(float zoom)
set Minimum zoomsetImageBitmap(Bitmap bm)
set BitmapreplaceBitmap(Bitmap bm)
Replace Bitmap without changing the image matrixsetGestureEnabled(boolean enabled)
Enable/Disable Cropper gesturessetDebug(boolean debug)
- Debugging modecropToCenter()
- Set Image in the center with square crop viewfitToCenter()
- Fit Image in the center (no cropping view)setPaddingColor(int color)
- Set Color of square image paddingsetMakeSquare(boolean status)
- If you want to add padding in the cropped image (if cropped image is not square)isMakeSquare()
- Check if cropper will give a square image or notinitWithFitToCenter(boolean fitToCenter)
- Cropper will fit image to center instead of cropping to center when bitmap is set.getCroppedBitmap()
- Get Cropped BitmapgetCroppedBitmapAsync()
- Crop bitmap in background thread and get result viaCropperCallback
.release()
- Remove and Recycle Bitmap
Styleables
nocropper__grid_color
- Color of the gridnocropper__grid_thickness
- Thickness of grid linesnocropper__grid_opacity
- Opacity of grid linesnocropper__padding_color
- Color of the image paddingnocropper__add_padding_to_make_square
- booleannocropper__fit_to_center
- boolean - Fit image to center instead of crop when you set a bitmap
0.1 to 0.2 update note:
All the styleables are renamed to have prefix nocropper__
so as not to have collision issues with other resource attributes. By collision I mean, your app will not build if it has to resources attributes with same name.
Licenses and Release History
NoCropper binaries and source code can be used according to the Apache License, Version 2.0.