I'm building an image processing app and have also returned null when trying these methods. My console returned not an error but a degub statement like this
D/skia: --- decoder->decode returned false
Here is what I found that will get any bitmap to load throughout my application
1) correct file name with appropriate permissions
2) Scale image down when appropriate
3) If you need a large image set it under you manifest like so
<application
android:largeHeap="true"
</application>
Using a large heap is not a substitute for displaying the correct image size. Here is an example of the code I use directly from androids docs
public Bitmap getRawImageThumb(Context mContext)
{
Bitmap b = null;
int reqHeight = 100, reqWidth = 100;
String filename = mContext.getFilesDir().toString() + "/" + rawFileName;
Log.d(TAG, "processRawReceipt: " + rawFileName);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
//options.inPreferredConfig = Bitmap.Config.ARGB_8888;
BitmapFactory.decodeFile(filename, options);
int height = options.outHeight;
int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
final int halfHeight = height / 2;
final int halfWidth = width / 2;
// Calculate the largest inSampleSize value that is a power of 2 and keeps both
// height and width larger than the requested height and width.
while ((halfHeight / inSampleSize) >= reqHeight
&& (halfWidth / inSampleSize) >= reqWidth) {
inSampleSize *= 2;
}
}
options.inSampleSize = inSampleSize;
options.inJustDecodeBounds = false;
Log.d(TAG, "getRawImage: " + String.valueOf(height) + " " + String.valueOf(width) + " " + String.valueOf(inSampleSize));
b = BitmapFactory.decodeFile(filename, options);
return b;
}