All Projects → soulqw → Coco

soulqw / Coco

Licence: apache-2.0
基于kotlin、简洁易用的调用系统拍照或图片选择库

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Coco

Imagepicker
📸Image Picker for Android, Pick an image from Gallery or Capture a new image with Camera
Stars: ✭ 623 (+125.72%)
Mutual labels:  camera, image, imagepicker
Picker
Picker - A CameraX based WhatsApp Style Image-Video Picker
Stars: ✭ 69 (-75%)
Mutual labels:  camera, image, imagepicker
Rximagepicker
Android图片相册预览选择器、支持AndroidX,支持图片的单选、多选、图片预览、图片文件夹切换、在选择图片时调用相机拍照
Stars: ✭ 85 (-69.2%)
Mutual labels:  camera, image, imagepicker
Cameraengine
🐒📷 Camera engine for iOS, written in Swift, above AVFoundation. 🐒
Stars: ✭ 554 (+100.72%)
Mutual labels:  camera, image
Opalimagepicker
A multiple image picker for iOS, written in Swift
Stars: ✭ 165 (-40.22%)
Mutual labels:  image, imagepicker
Ypimagepicker
📸 Instagram-like image picker & filters for iOS
Stars: ✭ 3,661 (+1226.45%)
Mutual labels:  camera, imagepicker
Pictureselectorlight
Picture Selector Library for Android or 图片选择器
Stars: ✭ 145 (-47.46%)
Mutual labels:  camera, image
Gpuimage X
A Cross-platform (for both Android & iOS) Framework for GPU-based Filters, Video and Image Processing.
Stars: ✭ 154 (-44.2%)
Mutual labels:  camera, image
Croperino
📷 A simple image cropping tool that provides gallery or camera help for Native Android (Java)
Stars: ✭ 176 (-36.23%)
Mutual labels:  camera, image
Bottomsheet Imagepicker
Modern image picker for Android
Stars: ✭ 267 (-3.26%)
Mutual labels:  image, imagepicker
Album
🍉 Album and Gallery for Android platform.
Stars: ✭ 2,430 (+780.43%)
Mutual labels:  camera, image
Awesomeimagepicker
Awesome Image Picker library will pick images/gifs with beautiful interface. Supports image or gif, Single and Multiple Image selection.
Stars: ✭ 160 (-42.03%)
Mutual labels:  image, imagepicker
Imageselector
🌁 Android 图片选择器。充分自由定制,极大程度简化使用,支持图库多选/图片预览/单选/照片裁剪/拍照/自定义图片加载方式/自定义色调/沉浸式状态栏
Stars: ✭ 1,310 (+374.64%)
Mutual labels:  image, imagepicker
XGImagePickerController
iOS相册图片/视频选择器
Stars: ✭ 32 (-88.41%)
Mutual labels:  camera, imagepicker
Matisse
基于知乎Matisse增强,一行代码实现图片/视频选择,裁剪,微信同款视频录制和拍照,无需权限申请!
Stars: ✭ 174 (-36.96%)
Mutual labels:  camera, imagepicker
MJMediaPicker
A Custom Class to select media from camera ,video or photo library by just adding a single file
Stars: ✭ 15 (-94.57%)
Mutual labels:  camera, imagepicker
ProPicker
ProPicker is a file picker (image, video, file) library for Android. It helps you to pick any file and return the result in a convenient way
Stars: ✭ 25 (-90.94%)
Mutual labels:  camera, imagepicker
Pigeon
Pigeon is a simple 3D printed cloud home surveillance camera project that uses the new Raspberry Pi Zero W
Stars: ✭ 266 (-3.62%)
Mutual labels:  camera
Focus Points
Plugin for Lightroom to show which focus point was active in the camera when a photo was taken
Stars: ✭ 272 (-1.45%)
Mutual labels:  camera
Selene
A C++17 image representation, processing and I/O library.
Stars: ✭ 266 (-3.62%)
Mutual labels:  image

CoCo

Hex.pm Hex.pm Hex.pm Hex.pm

一款小而美的的Android系统相机拍照、系统相册选择、裁剪库🐵

  • 一行代码完成从系统相机拍照、系统相册选择图片、系统裁剪
  • 内部适配 7.0 FileProvider文件处理,无需自己额外处理
  • 默认图片处理器自带两种图片压缩策略,并可按需自定义图片处理器
  • 支持Activity、Fragment,图片异步处理自动绑定相关容器生命周期
  • 全新设计的APi-更灵活-更易于理解
  • 完全基于Kotlin编写,与Java兼容
  • 全面适配AndroidX、配置简单,导入方便

Installation:

image

dependencies {
    implementation 'com.qw:coco:1.1.2'
}
最新Release 改动:
  • Pick 选图在 Range.PICK_CONTENT 模式下可以指定过滤文件类型,如PNG、JPG、GIF等,默认所有格式
  • CoCo 默认回调增加抽象类实现 CoCoAdapter

CoCo 1.0.0 + 将迎来历史上最大的更新:

强烈建议您迁移到最新的APi,方便后续新功能的拓展,老版本最后Release 版本将维护至0.3.1,后续不再更新(分支master_1.0.0_below)。

Usage:

基本用法

  • 调用系统相机拍照
       CoCo.with(this@MainActivity)
                       .take(createSDCardFile())
                       .start(object : CoCoAdapter<TakeResult>() {

                           override fun onSuccess(data: TakeResult) {
                               iv_image.setImageBitmap(Utils.getBitmapFromFile(data.savedFile!!.absolutePath))
                           }
                       })

效果图:

image

  • 调用系统相册选择图片:
        CoCo.with(this@MainActivity)
                    .pick()
                    .start(object : CoCoAdapter<PickResult>() {
                        override fun onSuccess(data: PickResult) {

                        iv_image.setImageURI(data.originUri)

                        }
                    })
效果图:

image

  • 处理我们拿到的原图:

上述以上是原图的情形,通常情况下,我们常常要对原图做一些处理,比如压缩等,所以CoCo 提供了dispose操作符,方便获得图片之后做一些处理:

        //选择图片后压缩
         CoCo.with(this)
                .pick()
                //切换操作符
                .then()
                .dispose()
                .start(object : CoCoAdapter<DisposeResult>() {
                    override fun onSuccess(data: DisposeResult) {
                        iv_image.setImageBitmap(data.compressBitmap)
                    }
                })

我们通过 then 操作符来完成操作符的组合,可以进行一些列操作符的串联流式处理。

dispose 操作符:

dispose操作符可以自动在子线程处理我们要处理的文件,并且自动绑定with()容器中的生命周期

它不仅可以和其它操作符组合使用:
 CoCo.with(this)
                .take(createSDCardFile())
                .then()
                .dispose()
                .start(object : CoCoAdapter<DisposeResult>() {

                    override fun onSuccess(data: DisposeResult) {
                        iv_image.setImageBitmap(Utils.getBitmapFromFile(data.savedFile!!.absolutePath))
                    }
                })
它还可以单独使用:
        CoCo.with(this)
                .dispose()
                .origin(imageFile.path)
                .start(object : CoCoAdapter<DisposeResult>() {

                    override fun onSuccess(data: DisposeResult) {
                        iv_image.setImageBitmap(data.compressBitmap)
                    }
                })
系统默认Default 图片处理器可以帮我们完成图片处理,也可自定义处理逻辑:
              CoCo.with(this)
                .dispose()
                .disposer(CustomDisposer())
              //.disposer(DefaultImageDisposer())
                .origin(imageFile.path)
                .start(object : CoCoAdapter<DisposeResult>() {

                    override fun onSuccess(data: DisposeResult) {
                        iv_image.setImageBitmap(data.compressBitmap)
                    }
                })

                            /**
             * custom disposer
             * rotation image
             */
            class CustomDisposer : Disposer {
                override fun disposeFile(originPath: String, targetToSaveResult: File?): DisposeResult {
                    return DisposeResult().also {
                        var bitmap = QualityCompressor()
                            .compress(originPath, 80)
                        val m = Matrix()
                        m.postRotate(90f)
                        bitmap = Bitmap.createBitmap(
                            bitmap!!, 0, 0, bitmap.width,
                            bitmap.height, m, true
                        )
                        it.savedFile = targetToSaveResult
                        it.compressBitmap = bitmap
                    }
                }
            }

Crop操作符:

让我可以指定一个图片文件提供给系统裁剪处理:

    CoCo.with(this@CropActivity)
                .crop(imageFile)
                .start(object : CoCoAdapter<CropResult>() {

                    override fun onSuccess(data: CropResult) {
                        iv_image.setImageBitmap(data.cropBitmap)
                    }

                })

当然,也可以组合原有操作符一起使用:

  CoCo.with(this@MainActivity)
                    .pick()
                    .then()
                    .crop()
                    .start(object : CoCoAdapter<CropResult>() {

                        override fun onSuccess(data: CropResult) {
                            iv_image.setImageBitmap(data.cropBitmap)
                        }
                    })

效果图:

image

  • 其它功能:
每个操作符都可以添加回调监听:
  CoCo.with(this@PickPictureActivity)
                .pick()
                .range(Range.PICK_CONTENT)
//                .range(Range.PICK_DICM)
                .callBack(object : PickCallBack {

                    override fun onFinish(result: PickResult) {
                        Log.d(MainActivity.TAG, "pick onFinish${result}")
                    }

                    override fun onCancel() {
                        Log.d(MainActivity.TAG, "pick onCancel")
                    }

                    override fun onStart() {
                        Log.d(MainActivity.TAG, "pick onStart")
                    }

                }).start(object : CoCoCallBack<PickResult> {

                    override fun onSuccess(data: PickResult) {
                        iv_image.setImageURI(data.originUri)
                    }

                    override fun onFailed(exception: Exception) {}
                })
  • 半流程图: image

更多功能可参考Demo

截图:

image

原理和详细设计分享可参考这里

联系我(注明来意):

在这里插入图片描述

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].