Skip to content Skip to sidebar Skip to footer

Android: Bitmapfactory.decodefile / Opencv Does Return Invaild Bitmap

I'm taking a picture with the camera activity and then try to read it from the saved location. Unfortunately the Bitmap returnd by: Bitmap bimage = BitmapFactory.decodeFile( path )

Solution 1:

Samsung has some issues with camera intent Photo capture Intent causes NullPointerException on Samsung phones only

Try this way

// to call camera

String_path= Environment.getExternalStorageDirectory()
                    + File.separator + "TakenFromCamera.png";
            Filefile=newFile(_path);
            UrioutputFileUri= Uri.fromFile(file);
            Intentintent=newIntent(
                    android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
            startActivityForResult(intent, 1212);

// in activity onResult

if (requestCode == 1212) {
            String_path= Environment.getExternalStorageDirectory()
                    + File.separator + "TakenFromCamera.png";
            mBitmap = BitmapFactory.decodeFile(_path);
            if (mBitmap == null) {
            } else {
                Intentintent=newIntent(AYGCamActivity.this,
                        myGalleryImage.class);

                startActivity(intent);
            }

        }

Post a Comment for "Android: Bitmapfactory.decodefile / Opencv Does Return Invaild Bitmap"