in my App I need to scale an image, this works with normaly. But when a big pictured will be loaded then the decodeStream method returns null. Currently it does not work when the image was bigger than 6 MB (5616x3744)
Does someone know why this happens and what can i do to fix this?
public static Bitmap scaleImage(final String filepath, int height, int width) throws IOException{
    if (filepath == null){
        Log.e(TAG, "cannot create Thumbnail without file");
        return null;
    }
    File f = new File(filepath);
    InputStream is = new FileInputStream(f); 
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeStream(is, null, options);
    is.close();
    final int imageHeight = options.outHeight;
    final int imageWidth = options.outWidth;
    String imageType = options.outMimeType;
    final int thumbnailHeight = height;
    final int thumbnailWidth = width;
    int heightRatio = Math.round((float) imageHeight) / Math.round((float) thumbnailHeight);
    int widthRatio = Math.round((float) imageWidth) / Math.round((float) thumbnailWidth);
    int inSampleSize = 0;
    if (heightRatio < widthRatio){
        inSampleSize =  heightRatio ;
    }
    else{
        inSampleSize =  widthRatio;
    }
    options.inSampleSize = inSampleSize;
    // Decode bitmap with inSampleSize set
    int retrySteps = 0;
    InputStream is2 = new FileInputStream(f);
    Bitmap bmp = null;
    for (int i = 0; i < 5; i++){
        options.inJustDecodeBounds = false;
        try {
            bmp = BitmapFactory.decodeStream(is2, null, options);
            if (bmp != null){
                i = 10;             
            }
            else{
                System.gc();    
                SystemClock.sleep(i * 1000);
                options.inSampleSize = inSampleSize + 1;
            }
        } catch (OutOfMemoryError e) {
            System.gc();    
            SystemClock.sleep(i * 1000);
        }
    }
    is2.close();        
    return bmp;
thanks