public Bitmap decodeSampledBitmapFromFile(File inputFile,int reqWidth,int reqHeight){
  InputStream is=null;
  try {
    try {
      is=new FileInputStream(inputFile);
    }
 catch (    Exception e) {
      return null;
    }
    final BitmapFactory.Options options=new BitmapFactory.Options();
    options.inJustDecodeBounds=true;
    BitmapFactory.decodeStream(is,null,options);
    options.inSampleSize=calculateInSampleSize(options,reqWidth,reqHeight);
    options.inJustDecodeBounds=false;
    options.inPurgeable=true;
    try {
      is=new FileInputStream(inputFile);
    }
 catch (    FileNotFoundException e) {
      return null;
    }
    return BitmapFactory.decodeStream(is,null,options);
  }
  finally {
    try {
      if (is != null) {
        is.close();
      }
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
}

public Bitmap decodeSampledBitmapFromFile ( File inputFile , int reqWidth , int reqHeight ) { InputStream is = null ; try { try { is = new FileInputStream ( inputFile ) ; } catch ( Exception e ) { return null ; } final BitmapFactory . Options options = new BitmapFactory . Options ( ) ; options . inJustDecodeBounds = true ; BitmapFactory . decodeStream ( is , null , options ) ; options . inSampleSize = calculateInSampleSize ( options , reqWidth , reqHeight ) ; options . inJustDecodeBounds = false ; options . inPurgeable = true ; try { is = new FileInputStream ( inputFile ) ; } catch ( FileNotFoundException e ) { return null ; } return BitmapFactory . decodeStream ( is , null , options ) ; } finally { try { if ( is != null ) { is . close ( ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } }
resamples the specified input image file to avoid oom errors .
