我正在用相机 Activity 拍照,然后尝试从保存的位置读取它。不幸的是,位图由以下方式返回:
Bitmap bimage = BitmapFactory.decodeFile( path );
Mat img = Highgui.imread(path);
bmp = Bitmap.createBitmap(img.cols(), img.rows(), Config.ARGB_8888);
Utils.matToBitmap(img, bmp);
BitmapFactory.decodeFile( path );
最佳答案
三星的相机意图Photo capture Intent causes NullPointerException on Samsung phones only有一些问题
试试这个
// call 相机
String _path = Environment.getExternalStorageDirectory()
+ File.separator + "TakenFromCamera.png";
File file = new File(_path);
Uri outputFileUri = Uri.fromFile(file);
Intent intent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, 1212);
if (requestCode == 1212) {
String _path = Environment.getExternalStorageDirectory()
+ File.separator + "TakenFromCamera.png";
mBitmap = BitmapFactory.decodeFile(_path);
if (mBitmap == null) {
} else {
Intent intent = new Intent(AYGCamActivity.this,
myGalleryImage.class);
startActivity(intent);
}
}
关于android - Android:BitmapFactory.decodeFile/OpenCV确实返回了无效的位图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9044909/