标签:getwidth hot valueof 权限 abs rmi action dia bit
case TAKE_PICTURE:
Intent openCameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Uri imageUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(),"image.jpg"));
//指定照片保存路径(SD卡),image.jpg为一个临时文件,每次拍照后这个图片都会被替换
openCameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(openCameraIntent, TAKE_PICTURE)
Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory()+"/image.jpg");
if(bitmap!=null) {
Bitmap newBitmap = ImageTools.zoomBitmap(bitmap, bitmap.getWidth() / SCALE, bitmap.getHeight() / SCALE);
//由于Bitmap内存占用较大,这里需要回收内存,否则会报out of memory异常
bitmap.recycle();
//将处理过的图片显示在界面上,并保存到本地
iv_image.setImageBitmap(newBitmap);
ImageTools.savePhotoToSDCard(newBitmap, Environment.getExternalStorageDirectory().getAbsolutePath(), String.valueOf(System.currentTimeMillis()));
}
break;
一开始第一句话说我 permission denied,所以bitmap是null;
解决:targetSdk=22 时,按以往权限管理处理,修改targetsdk https://jingyan.baidu.com/article/f71d6037af54131ab741d16d.html
// Bundle extras =data.getExtras();
// if(extras!=null) {
// Bitmap bitmap = extras.getParcelable("data");
// iv_image.setImageBitmap(bitmap);
这种写法图片压缩严重。
标签:getwidth hot valueof 权限 abs rmi action dia bit
原文地址:http://www.cnblogs.com/code666/p/6961081.html