android imagecropper 图片大小,Android-Image-Cropper:Android图片裁剪库

Android Image Cropper

625332134c6f4d4600884b99daebf603.png625332134c6f4d4600884b99daebf603.png625332134c6f4d4600884b99daebf603.png

Powerful (Zoom, Rotation, Multi-Source), customizable (Shape, Limits, Style), optimized (Async, Sampling, Matrix) and simple image cropping library for Android.

625332134c6f4d4600884b99daebf603.png

Usage

For a working implementation, please have a look at the Sample Project

Include the library

compile 'com.theartofdev.edmodo:android-image-cropper:2.7.+'

Add permissions to manifest

Add this line to your Proguard config file

-keep class android.support.v7.widget.** { *; }

Using Activity

Add CropImageActivity into your AndroidManifest.xml

android:theme="@style/Base.Theme.AppCompat"/>

Start CropImageActivity using builder pattern from your activity

// start picker to get image for cropping and then use the image in cropping activity

CropImage.activity()

.setGuidelines(CropImageView.Guidelines.ON)

.start(this);

// start cropping activity for pre-acquired image saved on the device

CropImage.activity(imageUri)

.start(this);

// for fragment (DO NOT use `getActivity()`)

CropImage.activity()

.start(getContext(), this);

Override onActivityResult method in your activity to get crop result

@Override

public void onActivityResult(int requestCode, int resultCode, Intent data) {

if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {

CropImage.ActivityResult result = CropImage.getActivityResult(data);

if (resultCode == RESULT_OK) {

Uri resultUri = result.getUri();

} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {

Exception error = result.getError();

}

}

}

Using View

Add CropImageView into your activity

xmlns:custom="http://schemas.android.com/apk/res-auto"

android:id="@+id/cropImageView"

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_weight="1"/>

Set image to crop

cropImageView.setImageUriAsync(uri);

// or (prefer using uri for performance and better user experience)

cropImageView.setImageBitmap(bitmap);

Get cropped image

// subscribe to async event using cropImageView.setOnCropImageCompleteListener(listener)

cropImageView.getCroppedImageAsync();

// or

Bitmap cropped = cropImageView.getCroppedImage();

Features

Built-in CropImageActivity.

Set cropping image as Bitmap, Resource or Android URI (Gallery, Camera, Dropbox, etc.).

Image rotation/flipping during cropping.

Auto zoom-in/out to relevant cropping area.

Auto rotate bitmap by image Exif data.

Set result image min/max limits in pixels.

Set initial crop window size/location.

Request cropped image resize to specific size.

Bitmap memory optimization, OOM handling (should never occur)!

API Level 14.

More..

Customizations

Cropping window shape: Rectangular or Oval (cube/circle by fixing aspect ratio).

Cropping window aspect ratio: Free, 1:1, 4:3, 16:9 or Custom.

Guidelines appearance: Off / Always On / Show on Toch.

Cropping window Border line, border corner and guidelines thickness and color.

Cropping background color.

For more information, see the GitHub Wiki.

Posts

Change log

2.7.0

Update gradle wrapper to 4.4

Update support library to 27.1.1 and set is statically! (thx @androideveloper)

Fix NPE in activity creation by tools (thx @unverbraucht)

More translations (thx @gwharvey, @dlackty, @JairoGeek, @shaymargolis)

2.6.0

Update to sdk v27

Update to gradle v3

2.5.1

Try solve manifest merger issue by adding transitive flag #405 (thx @j-garin)

Use thread pool executors for async image loading and cropping operations to prevent app hang if default executor is busy (thx @ruifcardoso)

Fix image rotation breaking min/max crop result restrictions #401

Propagate all extra data set on start crop activity intent back in crop result intent #352

License

Originally forked from edmodo/cropper.

Copyright 2016, Arthur Teplitzki, 2013, Edmodo, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值