项目作者: NAXAM

项目描述 :
Xamarin Binding Library for Yalantis uCrop library
高级语言: C#
项目地址: git://github.com/NAXAM/ucrop-android-binding.git
创建时间: 2017-06-11T15:51:45Z
项目社区:https://github.com/NAXAM/ucrop-android-binding

开源协议:MIT License

下载


XAMARIN ANDROID BINDING LIBRARY

  1. uCrop - Image Cropping Library for Android

Usage

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

Get it on Google Play

  1. Include the library via nuget

    1. Install-Package Naxam.uCrop.Droid
  2. Add UCropActivity into your AndroidManifest.xml

    1. <activity
    2. android:name="com.yalantis.ucrop.UCropActivity"
    3. android:screenOrientation="portrait"
    4. android:theme="@style/Theme.AppCompat.Light.NoActionBar"></activity>
  3. The uCrop configuration is created using the builder pattern.

    1. UCrop.Of(sourceUri, destinationUri)
    2. .WithAspectRatio(16, 9)
    3. .WithMaxResultSize(maxWidth, maxHeight)
    4. .Start(context);
  1. Override OnActivityResult method and handle uCrop result.

    1. protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) {
    2. if (resultCode == Result.Ok && requestCode == UCrop.RequestCrop) {
    3. Uri resultUri = UCrop.GetOutput(data);
    4. } else if (resultCode == UCrop.ResultError) {
    5. Throwable cropError = UCrop.GetError(data);
    6. }
    7. }
  2. You may want to add this to your PROGUARD config:

    1. -dontwarn com.yalantis.ucrop**
    2. -keep class com.yalantis.ucrop** { *; }
    3. -keep interface com.yalantis.ucrop** { *; }

Customization

If you want to let your users choose crop ratio dynamically, just do not call WithAspectRatio(x, y).

uCrop builder class has method WithOptions(UCrop.Options options) which extends library configurations.

Currently you can change:

  • image compression format (e.g. PNG, JPEG, WEBP), compression
  • image compression quality [0 - 100]. PNG which is lossless, will ignore the quality setting.
  • whether all gestures are enabled simultaneously
  • maximum size for Bitmap that is decoded from source Uri and used within crop view. If you want to override default behaviour.
  • toggle whether to show crop frame/guidelines
  • setup color/width/count of crop frame/rows/columns
  • choose whether you want rectangle or oval crop area
  • the UI colors (Toolbar, StatusBar, active widget state)
  • and more…

Compatibility

  • Library - Android ICS 4.0+ (API 14) (Android GINGERBREAD 2.3+ (API 10) for versions <= 1.3.2)
  • Sample - Android ICS 4.0+ (API 14)
  • CPU - armeabi armeabi-v7a x86 x86_64 arm64-v8a (for versions >= 2.1.2)

License

This binding is licensed under the MIT license, but the native Java library is license under the Apache License by Yalantis.

  1. Copyright 2017, Yalantis
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.