Android图片剪切库:scissors

jopen 8年前

Scissors

Fixed viewport image cropping library for Android with built-in support for Picasso or Glide.

Usage

Seescissors-sample.

  • Include it on your layout:
    <com.lyft.android.scissors.CropView      android:id="@+id/crop_view"      android:layout_width="match_parent"      android:layout_height="match_parent"      app:cropviewViewportHeightRatio="1"      />

  • Set a Bitmap to be cropped. In example by callingcropView.setImageBitmap(someBitmap);
  • CallBitmap croppedBitmap = cropView.crop();to obtain a cropped Bitmap to match viewport dimensions

Extensions

Scissors comes with handy extensions which help with common tasks like:

Loading a Bitmap

To load a Bitmap automatically with Picasso or Glide intoCropViewuse as follows:

cropView.extensions()      .load(galleryUri);

Cropping into a File

To save a cropped Bitmap into aFileuse as follows:

cropView.extensions()      .crop()      .quality(87)      .format(PNG)      .into(croppedFile))

Download

compile 'com.lyft:scissors:1.0.1'

Snapshots of development version are available in Sonatype'ssnapshotsrepository.

项目主页:http://www.open-open.com/lib/view/home/1448373865642