diff --git a/CHANGELOG.md b/CHANGELOG.md
index 66e20fe..9ed6d9d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,18 @@
Change Log
=========
+## Version 1.1.0
+* Support large size image(load/crop)
+* Improve rotation algorithm
+* Drop support for SDK level 9
+* Add CropMode 'CIRCLE_SQUARE'
+* Remove getRectBitmap() (Use 'CIRCLE_SQUARE' mode instead)
+* Shorten CropMode name(ex. RATIO_FIT_IMAGE -> FIT_IMAGE)
+* Add prefix to attrs(ex. cropMode -> scv_crop_mode)
+* Add animation
+* Support maximum output size
+* Support fixed output size(width/height)
+* Add debug display
+
## Version 1.0.16
* Fixed bug x + width must be <= bitmap.width() (#40)
diff --git a/README.md b/README.md
index 1135946..0dcb4a8 100644
--- a/README.md
+++ b/README.md
@@ -7,28 +7,37 @@
The SimpleCropView is an image cropping library for Android.
It simplifies your code for cropping image and provides an easily customizable UI.
-Supported on API Level 9 and above.
+Supported on API Level 10 and above.
-![demo](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/gif/demo_basic_usage.gif)
+![demo](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/1.1.0/demo_basic_usage.gif)
##Table of Contents
* [Download](#download)
-* [Image Cropping](#image-cropping)
-* [Image Rotation](#image-rotation)
+* [Example](#example)
+ * [Image Cropping](#image-cropping)
+ * [Image Rotation](#image-rotation)
+* [Load Image](#load-image)
+* [Crop and Save Image](#crop-and-save-image)
+ * [Compress Format](#compress-format)
+ * [Compress Quality](#compress-quality)
* [Customization](#customization)
+ * [Maximum Output Size](#maximum-output-size)
+ * [Fixed Output Size](#fixed-output-size)
* [CropMode](#cropmode)
- * [Circle Crop](#circle-crop)
* [MinimumFrameSize](#minimumframesize)
* [InitialFrameScale](#initialframescale)
* [Color](#color)
* [Stroke Weight and Handle Size](#stroke-weight-and-handle-size)
* [Handle Touch Padding](#handle-touch-padding)
* [Handle and Guide ShowMode](#handle-and-guide-showmode)
+ * [Animation](#animation)
* [Picasso and Glide Compatibility](#picasso-glide-compatibility)
+* [Debug](#debug)
* [XML Attributes](#xml-attributes)
-* [Developed By](#developed-by)
+* [Developed By](#developed-by)
+* [Users](#users)
* [License](#license)
##Download
@@ -39,96 +48,157 @@ repositories {
jcenter()
}
dependencies {
- compile 'com.isseiaoki:simplecropview:1.0.16'
+ compile 'com.isseiaoki:simplecropview:1.1.0'
}
```
-##Image Cropping
+##Example
+
+###Image Cropping
+
+Add permission in `AndroidManifest.xml` file.
+
+```xml
+
+
+```
Add the `com.isseiaoki.simplecropview.CropImageView` to your layout XML file.
>**NOTE:** The image is scaled to fit the size of the view by maintaining the aspect ratio. `WRAP_CONTENT` will be ignored.
-```xml
-
-
-
-
-
-
-
-
-
+```xml
+
+
+
```
-Set image, and get cropped image.
+Load image from sourceUri.
+
+
+```java
+
+mCropView = (CropImageView) findViewById(R.id.cropImageView);
+
+mCropView.startLoad(
+
+ sourceUri,
+
+ new LoadCallback() {
+ @Override
+ public void onSuccess() {}
+
+ @Override
+ public void onError() {}
+});
+
+```
+Crop image and save cropped bitmap in saveUri.
```java
-public class MainActivity extends Activity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
-
- final CropImageView cropImageView = (CropImageView)findViewById(R.id.cropImageView);
- final ImageView croppedImageView = (ImageView)findViewById(R.id.croppedImageView);
-
- // Set image for cropping
- cropImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.mipmap.sample5));
-
- Button cropButton = (Button)findViewById(R.id.crop_button);
- cropButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- // Get cropped image, and show result.
- croppedImageView.setImageBitmap(cropImageView.getCroppedBitmap());
- }
- });
+
+mCropView.startCrop(
+
+ saveUri,
+
+ new CropCallback() {
+ @Override
+ public void onSuccess(Bitmap cropped) {}
+
+ @Override
+ public void onError() {}
+ },
+
+ new SaveCallback() {
+ @Override
+ public void onSuccess(Uri outputUri) {}
+
+ @Override
+ public void onError() {}
}
+);
+
+```
+
+###Image Rotation
+
+![](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/1.1.0/demo_rotation.gif)
+
+SimpleCropView supports rotation by 90 degrees.
+
+```java
+
+cropImageView.rotateImage(CropImageView.RotateDegrees.ROTATE_90D); // rotate clockwise by 90 degrees
+cropImageView.rotateImage(CropImageView.RotateDegrees.ROTATE_M90D); // rotate counter-clockwise by 90 degrees
-}
```
-For a working implementation of this project see the `simplecropview-sample` folder.
+**For a working implementation of this project, see [sample project](https://github.com/IsseiAoki/SimpleCropView/tree/master/simplecropview-sample).**
+
+##Load Image
+
+* `setImageXXX()`(Sync method)
+
+This method loads the given Bitmap. If the bitmap size is too large, Exception occurs.
+
+* `startLoad(Uri sourceUri, LoadCallback callback)`(Async method, **RECOMMENDED**)
+
+This method loads Bitmap in efficient size from sourceUri.
+You don't have to care for filePath and image size.
+
+**REMEMBER** : `sourceUri` parameter will be used in `startCrop(Uri saveUri, CropCallback cropCallback, SaveCallback saveCallback)`.
+
+##Crop and Save Image
+
+* `getCroppedBitmap()`(Sync method)
+
+This method always use thumbnail bitmap set by `setImageXXX()` for cropping.
+It does not save cropped bitmap.
+
+* `startCrop(Uri saveUri, CropCallback cropCallback, SaveCallback saveCallback)`(Async Method, **RECOMMENDED**)
-##Image Rotation
+This method uses full size bitmap taken from `sourceUri` for cropping.
+If `sourceUri` is not set, it uses thumbnail bitmap.
+After cropping, it saves cropped image in `saveUri`.
-![](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/1.0.8/demo_rotate_image.gif)
+###Compress Format
-Code for rotating the image 90 degrees clockwise:
+You can use 3 compress format, `PNG`(default),`JPEG`, and `WEBP`.
```java
-CropImageView cropImageView = (CropImageView)findViewById(R.id.cropImageView);
-cropImageView.rotateImage(CropImageView.RotateDegrees.ROTATE_90D);
+setCompressFormat(Bitmap.CompressFormat.JPEG);
```
-You can also use `ROTATE_180D` and `ROTATE_270D`.
+###Compress Quality
+You can also set compress quality. `0`~`100`(default)
+
+```java
+setCompressQuality(90);
+```
##Customization
@@ -139,6 +209,24 @@ You can also use `ROTATE_180D` and `ROTATE_270D`.
[![](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/device-art/thumbnails/thumb6.jpg)](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/device-art/showcase6.jpg)
[![](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/device-art/thumbnails/thumb7.jpg)](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/device-art/showcase7.jpg)
+###Maximum Output Size
+You can set max size for output image. The output image will be scaled within given rect.
+
+```java
+setOutputMaxSize(300, 300);
+```
+
+###Fixed Output Size
+You can also set fixed output width/height.
+
+```java
+setOutputWidth(100); // If cropped image size is 400x200, output size is 100x50
+```
+
+```java
+setOutputHeight(100); // If cropped image size is 400x200, output size is 200x100
+```
+
###CropMode
The option for the aspect ratio of the image cropping frame.
@@ -148,61 +236,52 @@ CropImageView cropImageView = (CropImageView)findViewById(R.id.cropImageView);
cropImageView.setCropMode(CropImageView.CropMode.RATIO_16_9);
```
->**CropMode Values:**
->```
-RATIO_4_3, RATIO_3_4, RATIO_1_1, RATIO_16_9, RATIO_9_16, RATIO_FIT_IMAGE, RATIO_FREE, CIRCLE(1.0.8~)
+####Values
```
+FIT_IMAGE, RATIO_4_3, RATIO_3_4, SQUARE(default), RATIO_16_9, RATIO_9_16, FREE, CUSTOM, CIRCLE, CIRCLE_SQUARE
+```
+####Rect Crop
+`FREE`: *Non-Fixed aspect ratio mode*
+`RATIO_X_Y`, `SQUARE`: *Fixed aspect ratio mode*
+`FIT_IMAGE`: *Fixed aspect ratio mode. The same aspect ratio as the original photo.*
->`RATIO_FREE`: *Non-Fixed aspect ratio mode*
-`RATIO_X_Y`: *Fixed aspect ratio mode*
-`RATIO_FIT_IMAGE`: *Fixed aspect ratio mode. The same aspect ratio as the original photo.*
-`CIRCLE`: *Fixed aspect ratio mode. RATIO_1_1 + circle overlay. See [Circle Crop](#circle-crop) section for more details.*
-
->If you need other aspect ratio, use `setCustomRatio(int ratioX, int ratioY);`
+If you need other aspect ratio, use `setCustomRatio(int ratioX, int ratioY);`
-![demo](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/gif/demo_crop_mode.gif)
+![demo](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/1.1.0/demo_crop_mode_rect.gif)
-###Circle Crop
+####Circle Crop
-```java
-CropImageView cropImageView = (CropImageView)findViewById(R.id.cropImageView);
-cropImageView.setCropMode(CropImageView.CropMode.CIRCLE);
-```
+`CIRCLE`: *Fixed aspect ratio mode. Crop image as circle.*
+`CIRCLE_SQUARE`: *Fixed aspect ratio mode. Show guide circle, but save as square.(`getRectBitmap()` is removed.)*
-![](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/1.0.8/demo_circle_crop.gif)
-You can also use `custom:cropMode="circle"` in your layout XML.
+![](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/1.1.0/demo_crop_mode_circle.gif)
->If you need to show circle overlay but save as a square, your can use `getRectBitmap()`.(1.0.9~)
###MinimumFrameSize
-The minimum size of the image cropping frame in dp.
+The minimum size of the image cropping frame in dp.(default:50)
```java
CropImageView cropImageView = (CropImageView)findViewById(R.id.cropImageView);
cropImageView.setMinFrameSizeInDp(100);
```
-You can also use `custom:minFrameSize="100dp"` in your layout XML.
![demo](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/gif/demo_minimum_frame_size.gif)
###InitialFrameScale
-The initial frame size of the image cropping frame. (scale: 0.01 ~ 1.0. The default value is 0.75.)
+The initial frame size of the image cropping frame. `0.01`~`1.0`(default)
```java
CropImageView cropImageView = (CropImageView)findViewById(R.id.cropImageView);
cropImageView.setInitialFrameScale(1.0f);
```
-You can also use `custom:initialFrameScale="1.0"` in your layout XML.
| scale | Appearance |
|:-------------:|:-----:|
| 0.5 | |
-| 0.75 (default) | |
-| 1.0 | |
-
-You can also use `custom:initialFrameScale="1.0"` in your layout XML.
+| 0.75| |
+| 1.0 (default)| |
###Color
@@ -214,13 +293,6 @@ cropImageView.setFrameColor(getResources().getColor(R.color.frame));
cropImageView.setHandleColor(getResources().getColor(R.color.handle));
cropImageView.setGuideColor(getResources().getColor(R.color.guide));
```
-You can also use
-`custom:backgroundColor="#FFFFFFFB`
-`custom:overlayColor="#AA1C1C1C"`
-`custom:frameColor="@color/frame"`
-`custom:handleColor="@color/handle"`
-`custom:guideColor="@color/guide"`
-in your layout XML.
![](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/graphic/color-attributes.png)
@@ -232,11 +304,6 @@ cropImageView.setFrameStrokeWeightInDp(1);
cropImageView.setGuideStrokeWeightInDp(1);
cropImageView.setHandleSizeInDp(getResources().getDimension(R.dimen.handle_size));
```
-You can also use
-`custom:frameStrokeWeight="1dp"`
-`custom:guideStrokeWeight="1dp"`
-`custom:handleSize="8dp"`
-in your layout XML.
![](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/graphic/size-attributes.png)
@@ -248,7 +315,6 @@ Additional touch area for the image cropping frame handle.
CropImageView cropImageView = (CropImageView)findViewById(R.id.cropImageView);
cropImageView.setTouchPadding(16);
```
-You can also use `custom:touchPadding="16dp"` in your layout XML.
![](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/graphic/handle-touch-padding.png)
@@ -260,9 +326,9 @@ cropImageView.setHandleShowMode(CropImageView.ShowMode.SHOW_ALWAYS);
cropImageView.setGuideShowMode(CropImageView.ShowMode.SHOW_ON_TOUCH);
```
->**ShowMode Values:**
->```
-SHOW_ALWAYS, NOT_SHOW, SHOW_ON_TOUCH
+####Values
+```
+SHOW_ALWAYS(default), NOT_SHOW, SHOW_ON_TOUCH
```
| Handle ShowMode | Guide ShowMode | Appearance |
@@ -273,6 +339,31 @@ SHOW_ALWAYS, NOT_SHOW, SHOW_ON_TOUCH
| SHOW_ALWAYS | SHOW_ON_TOUCH | |
| SHOW_ON_TOUCH | NOT_SHOW | |
+###Animation
+SimpleCropView supports rotate animation and frame change animation.
+
+####Enabled
+Toggle whether to animate. `true` is default.
+
+```java
+setAnimationEnabled(true);
+```
+
+####Duration
+Set animation duration in milliseconds. `100` is default.
+
+```java
+setAnimationDuration(200);
+```
+
+####Interpolator
+Set interpolator of animation. `DecelerateInterpolator` is default.
+You can also use your custom interpolator.
+
+```java
+setInterpolator(new AccelerateDecelerateInterpolator());
+```
+
##Picasso and Glide Compatibility
`com.isseiaoki.simplecropview.CropImageView` is a kind of `ImageView`.
You can use it with Picasso or Glide as follows:
@@ -282,6 +373,7 @@ CropImageView cropImageView = (CropImageView)findViewById(R.id.cropImageView);
Picasso.with(context).load(imageUrl).into(cropImageView);
```
or
+
```java
CropImageView cropImageView = (CropImageView)findViewById(R.id.cropImageView);
Glide.with(context).load(imageUrl).into(cropImageView);
@@ -289,53 +381,77 @@ Glide.with(context).load(imageUrl).into(cropImageView);
>Some option does not work correctly because CropImageView does not support ImageView.ScaleType.
+##Debug
+You can use debug display.
+
+![](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/1.1.0/demo_debug.gif)
+
+```java
+setDebug(true);
+```
+
##XML Attributes
XML sample here.
```xml
-
+
```
| XML Attribute (custom:) | Related Method | Description |
|:---|:---|:---|
-| imgSrc | setImageResource(int resId) | Set source image. |
-| cropMode | setCropMode(CropImageView.CropMode mode) | Set crop mode. |
-| minFrameSize | setMinFrameSizeInDp(int minDp) | Set the image cropping frame minimum size in density-independent pixels. |
-| backgroundColor | setBackgroundColor(int bgColor) | Set view background color. |
-| overlayColor | setOverlayColor(int overlayColor) | Set image overlay color. |
-| frameColor | setFrameColor(int frameColor) | Set the image cropping frame color. |
-| handleColor | setHandleColor(int frameColor) | Set the handle color. |
-| guideColor | setGuideColor(int frameColor) | Set the guide color. |
-| handleSize | setHandleSizeInDp(int handleDp) | Set handle radius in density-independent pixels. |
-| touchPadding | setTouchPaddingInDp(int paddingDp) | Set the image cropping frame handle touch padding(touch area) in density-independent pixels. |
-| frameStrokeWeight | setFrameStrokeWeightInDp(int weightDp) | Set frame stroke weight in density-independent pixels. |
-| guideStrokeWeight | setGuideStrokeWeightInDp(int weightDp) | Set guideline stroke weight in density-independent pixels. |
-| guideShowMode | setGuideShowMode(CropImageView.ShowMode mode) | Set guideline show mode. |
-| handleShowMode | setHandleShowMode(CropImageView.ShowMode mode) | Set handle show mode. |
-| cropEnabled | setCropEnabled(boolean enabled) | Set whether to show the image cropping frame. |
+| scv_img_src | setImageResource(int resId) | Set source image. |
+| scv_crop_mode | setCropMode(CropImageView.CropMode mode) | Set crop mode. |
+| scv_background_color | setBackgroundColor(int bgColor) | Set view background color. |
+| scv_overlay_color | setOverlayColor(int overlayColor) | Set image overlay color. |
+| scv_frame_color | setFrameColor(int frameColor) | Set the image cropping frame color. |
+| scv_handle_color | setHandleColor(int frameColor) | Set the handle color. |
+| scv_guide_color | setGuideColor(int frameColor) | Set the guide color. |
+| scv_guide_show_mode | setGuideShowMode(CropImageView.ShowMode mode) | Set guideline show mode. |
+| scv_handle_show_mode | setHandleShowMode(CropImageView.ShowMode mode) | Set handle show mode. |
+| scv_handle_size | setHandleSizeInDp(int handleDp) | Set handle radius in density-independent pixels. |
+| scv_touch_padding | setTouchPaddingInDp(int paddingDp) | Set the image cropping frame handle touch padding(touch area) in density-independent pixels. |
+| scv_min_frame_size | setMinFrameSizeInDp(int minDp) | Set the image cropping frame minimum size in density-independent pixels. |
+| scv_frame_stroke_weight | setFrameStrokeWeightInDp(int weightDp) | Set frame stroke weight in density-independent pixels. |
+| scv_guide_stroke_weight | setGuideStrokeWeightInDp(int weightDp) | Set guideline stroke weight in density-independent pixels. |
+| scv_cropEnabled | setCropEnabled(boolean enabled) | Set whether to show the image cropping frame. |
+| scv_initial_frame_scale | setInitialFrameScale(float initialScale) | Set Set initial scale of the frame.(0.01 ~ 1.0) |
+| scv_animation_enabled | setAnimationEnabled(boolean enabled) | Set whether to animate. |
+| scv_animation_duration | setAnimationDuration(int durationMillis) | Set animation duration. |
+| scv_handle_shadow_enabled | setHandleShadowEnabled(boolean handleShadowEnabled) | Set whether to show handle shadows. |
##Developed By
- * Issei Aoki -
+Issei Aoki -
+
+##Users
+If you are using my library, please let me know your app name :)
##License
```