调用用相机拍照保存在本地

private void openCarama(int requsetCode, String path) {

                //requsetCode请求路径,path 保存路径

Intent getImageByCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

File file = new File(path);

try {

file.createNewFile();


// 这行代码很重要,没有的话会因为写入权限不够出一些问题

file.setWritable(true, false);

} catch (IOException e) {

}

file.mkdirs();

getImageByCamera.putExtra("return-data", false);

getImageByCamera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));

getImageByCamera.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());

getImageByCamera.putExtra("noFaceDetection", true);

mainActivity.photoPath = requsetCode;

startActivityForResult(getImageByCamera, requsetCode);

}

根据路径读取图片格式为bitmap 


/**

* 根据图片所在的路径,将图片转为Bitmap

* @param url

* @return

*/

public static Bitmap getLoacalBitmap(String url) {

try {

FileInputStream fis = new FileInputStream(url);

return BitmapFactory.decodeStream(fis);

} catch (FileNotFoundException e) {

e.printStackTrace();

return null;

}

}


p_w_picpathview.setImageBitmap(<根据getLoacalBitmap(url)>获取图片)