当前位置: 首页 > 软件库 > 手机/移动开发 > >

Android-Image-Cropper

授权协议 Apache-2.0 License
开发语言 Java
所属分类 手机/移动开发
软件类型 开源软件
地区 不详
投 递 者 朱锦
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Android Image Cropper

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

Crop

Usage

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

See GitHub Wiki for more info.

  1. Include the library
dependencies {
    api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
}

Add permissions to manifest

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Add this line to your Proguard config file

-keep class androidx.appcompat.widget.** { *; }

Using Activity

  1. Add CropImageActivity into your AndroidManifest.xml
<activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
  android:theme="@style/Base.Theme.AppCompat"/> <!-- optional (needed if default theme has no action bar) -->
  1. 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);
  1. 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

  1. Add CropImageView into your activity
<!-- Image Cropper fill the remaining available height -->
<com.theartofdev.edmodo.cropper.CropImageView
  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"/>
  1. Set image to crop
cropImageView.setImageUriAsync(uri);
// or (prefer using uri for performance and better user experience)
cropImageView.setImageBitmap(bitmap);
  1. 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.8.0

  • Fix crash on Android O (thx @juliooa)
  • Update to support library to AndroidX (thx @mradzinski)
  • Handle failure when selecting non image file (thx @uncledoc)
  • More translations (thx @jkwiecien, @david-serrano)

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)

See full change log.

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:

http://www.apache.org/licenses/LICENSE-2.0

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.

  • 图片裁剪是一个相对用的比较多的功能。正好近期用到了。 于是在最新的ChatGPT上询问了一番。。两次询问,得到的最优推荐依然是:Android-Image-Cropper。经过一番研究使用。。确实简单好用。直接看代码: 首先,你需要引入依赖: dependencies { api 'com.theartofdev.edmodo:android-image-cropper:2.8.+' }

  • Android-Image-Cropper图片裁剪库试用 Android-Image-Cropper试用 具体用法参考官方库wiki or demo build.gradle implementation'com.theartofdev.edmodo:android-image-cropper:2.8.0' AndroidManifest.xml <uses-permission android

  • 由于cropper截取计算左上坐标时没有考虑到图片比CropImageView小的情况,于是fork了一份并提交代码 库地址:https://github.com/zhangwei911/cropper

  • image-cropper插件引入后,会有很多默认功能,所有需求基本都可以满足; https://github.com/wx-plugin/image-cropper 第一步:在组件中添加image-cropper image-cropper.wxml文件 <view class='image-cropper' catchtouchmove='_preventTouchMove'> <vi

  • 支持圆形裁剪框,裁剪后生成圆形图案。 代码基于开源项目修改,github上项目链接:https://github.com/shengge/android-crop 还是贴下效果图:    说一下圆形裁剪实现部分: 1.UI方面,自定义CircleHighlightView继承至HighlightView(原有的矩形裁剪框实现),直接看draw方法实现 [java] view plaincopy在C

 相关资料
  • 一、简介 基于ViewPager的用户指引,广告图片Gallery,及自动轮播图片Gallery,使用起来超简单! GitHub地址:https://github.com/panxw/android-image-indicator 二、使用示例 1、广告图片Gallery   <com.allthelucky.common.view.ImageIndicatorView android:id

  • SmartImageView的设计初衷是来取代Android自带的ImgageView组件,另外它还提供了一些附加功能,如: 支持通过URL来加载图片; 支持从电话簿中加载图片; 异步加载图片; 图片被缓存在内存,以便下次快速加载显示; SmartImageView类可以被很容易扩展成对其它资源的调用;

  • Android-Universal-Image-Loader (Universal Image Loader for Android) 的目的就是为了实现异步的网络图片加载,支持多线程异步加载。

  • 实现图片的放大、缩小、截图功能。 [Code4App.com]

  • Universal Image Loader Library在使用android OS5.0.1版本的华为设备的android studio中进行初始化时认为该崩溃 原因:java.lang.ClassNotFoundException:在路径:DexPathList[[zip文件“/data/app/com.q8car.andriod.activity-2/base.apk”,zip文件“/da

  • 问题内容: 我正在尝试启动一个图像,该图像将使用内置的Android图像查看器写入到我的应用程序目录中。此图像已在应用程序的不同部分写入应用程序目录。获取以下文件时: File.exists()返回true。 如何启动内置​​的Android图像查看器来查看此文件?目前我正在做: 而且它一直在搅动: 10-11 13:09:24.367:INFO / ActivityManager(564):开始