项目
在 GitHub 查看 

TakuSemba/CropMe
关于
极其流畅、易于使用的裁剪库。
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文CropMe

Gradle
dependencies {
implementation 'com.github.takusemba:cropme:x.x.x'
}
Usage

This is an Android library for cropping images. Move images smoothly, and crop images precisely.
Use CropView in your xml file.
<com.takusemba.cropme.CropLayout
android:id="@+id/crop_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cropme_background_alpha="80%"
app:cropme_frame_height_percent="80%"
app:cropme_frame_width_percent="80%"
app:cropme_max_scale="2.0"
app:cropme_overlay_shape="rectangle"
app:cropme_with_border="true"
>
Set your image
cropView.setUri(uri);
// or
cropView.setBitmap(bitmap)
Crop it!
cropLayout.addOnCropListener(object : OnCropListener {
override fun onSuccess(bitmap: Bitmap) {
// do somethhing with bitmap.
}
override fun onFailure(e: Exception) {
// do error handling.
}
})
cropView.isOffFrame() // optionally check if the image is off the frame.
cropView.crop() // crop image
Attributes
| attribute | description | default |
|---|---|---|
| cropme_frame_width_percent | width of croppling frame | 80% |
| cropme_frame_height_percent | height of croppling frame | 80% |
| cropme_max_scale | maximum scale while cropping | 2.0 |
| cropme_with_border | if borders are shown while cropping | true |
| cropme_background_alpha | background alpha out side of cropping area | 80% |
| cropme_overlay_shape | shape of croppling frame | rectangle / circle / custom |
| cropme_custom_shape_layout | custom layout for custom shape | @layout/custom_layout |
Custom Overlay
If you want to show a custom overlay, you can customize the Overlay by extending CropOverlay.
You can see more detail in app module.
class CustomCropOverlay @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
cropOverlayAttrs: AttributeSet? = attrs
) : CropOverlay(context, attrs, defStyleAttr, cropOverlayAttrs) {
override fun drawBackground(canvas: Canvas, paint: Paint) {
// draw background
}
override fun drawCrop(canvas: Canvas, paint: Paint) {
// draw croppling frame
}
override fun drawBorder(canvas: Canvas, paint: Paint) {
// draw borders
}
}
Sample
Clone this repo and check out the app module.
Author
- Taku Semba
- Github - (https://github.com/takusemba)
- Twitter - (https://twitter.com/takusemba)
- Facebook - (https://www.facebook.com/takusemba)
Licence
Copyright 2017 Taku Semba.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License 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.
探索相关项目
加载中…