安卓拍照或选取相册后将目标图片压缩

压缩图片

https://www.jianshu.com/p/81e553fd0bc3

 

获取相册活动返回的图片的实际地址代码

// 获取相册图片真实地址
    //相册图片content地址 Intent { dat=content://media/external/images/media/53 flg=0x1 }
    // 实际地址 file:///storage/emulated/0/Pictures/IMG_20181126_053954.jpg
    private String getRealPathFromURI(Uri contentURI) {
        String result;
        Cursor cursor = getContentResolver().query(contentURI, null, null, null, null);
        if (cursor == null) {
            // Source is Dropbox or other similar local file path
            result = contentURI.getPath();
        }
        else {
            cursor.moveToFirst();
            int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
            result = cursor.getString(idx);
            cursor.close(); }
        return result;
    }

 

https://www.jianshu.com/p/81e553fd0bc3

posted @ 2018-11-26 15:00  老豆芽  阅读(398)  评论(0)    收藏  举报