Android圖片剪切庫:scissors
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.
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!