美文网首页
TakePhoto的照片选择器的使用

TakePhoto的照片选择器的使用

作者: 溜的丫披 | 来源:发表于2019-04-25 17:45 被阅读0次

TakePhoto的照片选择器的使用(多选)

参考项目地址 https://blog.csdn.net/iamchan/article/details/81261524
https://github.com/bumptech/glide 此项目中glide使用 3.7.0 高版本的报错 为啥`````俺也不知.
github地址https://github.com/crazycodeboy/TakePhoto
在按钮里面直接调用onClickTake(getTakePhoto);即可

public void onClickTake(TakePhoto takePhoto) {
    configCompress(takePhoto);
    takePhoto.onPickMultiple(1);//根据需求这里面放最大图片数 单选使用takePhoto.onPickFromGallery();
}

private void configCompress(TakePhoto takePhoto) {//压缩的配置
    int maxSize = Integer.parseInt("409600");//最大 压缩
    int width = Integer.parseInt("800");//宽
    int height = Integer.parseInt("800");//高
    CompressConfig config;
    config = new CompressConfig.Builder().setMaxSize(maxSize)
            .setMaxPixel(width >= height ? width : height)

            .enableReserveRaw(false)//拍照压缩后是否显示原图
            .create();
    takePhoto.onEnableCompress(config, false);//是否显示进度条

}

需要实现继承 TakePhotoActivity或者 TakePhotoFragment

实现 takeSuccess() takeFail() takeCancel()

takeSuccess方法中可以取到返回值的图片 像这样

public void takeSuccess(TResult result) {
    super.takeSuccess(result);
    Glide.with(getApplicationContext()).load(result.getImages().get(0).getCompressPath()).into(ivTest);
}

相关文章

网友评论

      本文标题:TakePhoto的照片选择器的使用

      本文链接:https://www.haomeiwen.com/subject/gbazgqtx.html