Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Jhuster/ImageCropper
A custom image cropper library on Android.
https://github.com/Jhuster/ImageCropper
Last synced: 3 months ago
JSON representation
A custom image cropper library on Android.
- Host: GitHub
- URL: https://github.com/Jhuster/ImageCropper
- Owner: Jhuster
- License: apache-2.0
- Created: 2015-01-10T12:56:11.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-05-07T02:14:29.000Z (over 7 years ago)
- Last Synced: 2024-06-16T05:35:47.019Z (5 months ago)
- Language: Java
- Homepage: http://ticktick.blog.51cto.com/823160/1601702
- Size: 1.43 MB
- Stars: 147
- Watchers: 5
- Forks: 32
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-github-android-ui - ImageCropper - 图片裁剪库 (图片)
README
ImageCropper
=========
A custom image cropper library on AndroidFeatures
=========
- Support moving/scale the crop window freely by finger
- Support set a fixed crop window size
- Support set the max crop window size
- Support set a fixed crop window's width/height aspect
- Support rotate the image when cropping
- Easy to integrate into your appScreenShot
=========Dependency
=========
(1) Add it in your root build.gradle at the end of repositories:
```groovy
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
```(2) Add the dependency
```groovy
allprojects {
compile 'com.github.Jhuster:ImageCropper:v1.1.1'
}
```Usage
=========
Declare the CropImageActivity in the main project's AndroidManifest.xml
```xml```
Declare the write_external_storage permission in the main project's AndroidManifest.xml
```xml```
Call these methods to run CropImage Activity
```java
//1. Using the CropIntent to help build the start intent
private void startCropImage() {// Create a CropIntent
CropIntent intent = new CropIntent();// Set the source image filepath/URL and output filepath/URL (Optional)
//intent.setImagePath("/sdcard/source.jpg");
intent.setOutputPath("/sdcard/cropped.jpg");// Set a fixed crop window size (Optional)
//intent.setOutputSize(640,480);// set the max crop window size (Optional)
//intent.setMaxOutputSize(800,600);// Set a fixed crop window's width/height aspect (Optional)
//intent.setAspect(3,2);// start ImageCropper activity with certain request code and listen for result
startActivityForResult(intent.getIntent(this), 0);
}
```Waiting for result
```java
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {if (resultCode != RESULT_OK) {
return;
}if (requestCode == 0) {
Uri croppedUri = data.getExtras().getParcelable(MediaStore.EXTRA_OUTPUT);
InputStream in = null;
try {
in = getContentResolver().openInputStream(croppedUri);
Bitmap b = BitmapFactory.decodeStream(in);
//mImageView.setImageBitmap(b);
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
}
super.onActivityResult(requestCode, resultCode, data);
}
```Contact
----------
Email:[email protected]