https://github.com/Tofira/ImagePickerWithCrop
A library designated for selecting an image via gallery or camera, with cropping abilities, in an easy way.
https://github.com/Tofira/ImagePickerWithCrop
Last synced: 7 months ago
JSON representation
A library designated for selecting an image via gallery or camera, with cropping abilities, in an easy way.
- Host: GitHub
- URL: https://github.com/Tofira/ImagePickerWithCrop
- Owner: Tofira
- Created: 2016-10-18T06:57:32.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-02T07:43:41.000Z (about 8 years ago)
- Last Synced: 2024-11-09T16:43:47.343Z (12 months ago)
- Language: Java
- Size: 1.41 MB
- Stars: 74
- Watchers: 6
- Forks: 26
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-github-android-ui - ImagePickerWithCrop - 指定选择图片的库 (图片)
README
# ImagePickerWithCrop
A library designated for selecting an image via gallery or camera, with cropping abilities, in an easy way.

Simple sample usage -
```java
new PickerBuilder(MainActivity.this, PickerBuilder.SELECT_FROM_CAMERA)
.setOnImageReceivedListener(new PickerBuilder.onImageReceivedListener() {
@Override
public void onImageReceived(Uri imageUri) {
Toast.makeText(MainActivity.this,"Got image - " + imageUri,Toast.LENGTH_LONG).show();
imageView.setImageURI(imageUri);
}
})
.start();
```
A slighly more customized example -
```java
new PickerBuilder(MainActivity.this, PickerBuilder.SELECT_FROM_CAMERA)
.setOnImageReceivedListener(new PickerBuilder.onImageReceivedListener() {
@Override
public void onImageReceived(Uri imageUri) {
Toast.makeText(MainActivity.this,"Got image - " + imageUri,Toast.LENGTH_LONG).show();
imageView.setImageURI(imageUri);
}
})
.setImageName("testImage")
.setImageFolderName("testFolder")
.withTimeStamp(false)
.setCropScreenColor(Color.CYAN)
.start();
```
##How to install
Import the following in your app's `Gradle` file -
```compile 'com.yalantis:ucrop:2.2.0'```
Copy the following files to your project -
```java
CameraPickerManager.java
GlobalHolder.java
ImagePickerManager.java
PickerBuilder.java
PickerManager.java
TempActivity.java
```
Next, add the following two Activities to your Manifest file -
```xml
```
Finally, add the following to your `styles.xml` file -
```xml
<item name="android:background">#33000000</item> <!-- Or any transparency or color you need -->
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
```
##How to use
* See the samples above.
* The picker will get the image from the Camera or the gallery based on the type attribute it receives. It can be one of the following -
`PickerBuilder.SELECT_FROM_CAMERA` or `PickerBuilder.SELECT_FROM_GALLERY`.
* The image will be provided through the `onImageReceivedListener` listener.
* The default image location is `/DCIM/[APP_NAME]/[APP_NAME]_[TIMESTAMP].jpg`, and it can be customized.
##Customization
The library offers several customization options -
* `setCropScreenColor(Color)` - default is the app's primary color.
* `setImageName(name)` - default it the app's name.
* `setImageFolderName(name)` - default it the app's name.
* `setCustomizedUcrop(UCrop)` - set your own UCrop, instead of the default conifgured one.
* `setOnPermissionRefusedListener(PickerBuilder.onPermissionRefusedListener)`
##Credits
The library uses the great cropping library Ucrop.