public static DecodeBitmapResult decodeSampledBitmap(Context context,Uri uri,int reqWidth,int reqHeight){
  try {
    ContentResolver resolver=context.getContentResolver();
    BitmapFactory.Options options=decodeImageForOption(resolver,uri);
    options.inSampleSize=Math.max(calculateInSampleSizeByReqestedSize(options.outWidth,options.outHeight,reqWidth,reqHeight),calculateInSampleSizeByMaxTextureSize(options.outWidth,options.outHeight));
    Bitmap bitmap=decodeImage(resolver,uri,options);
    return new DecodeBitmapResult(bitmap,options.inSampleSize);
  }
 catch (  Exception e) {
    throw new RuntimeException("Failed to load sampled bitmap: " + uri + "\r\n"+ e.getMessage(),e);
  }
}

public static DecodeBitmapResult decodeSampledBitmap ( Context context , Uri uri , int reqWidth , int reqHeight ) { try { ContentResolver resolver = context . getContentResolver ( ) ; BitmapFactory . Options options = decodeImageForOption ( resolver , uri ) ; options . inSampleSize = Math . max ( calculateInSampleSizeByReqestedSize ( options . outWidth , options . outHeight , reqWidth , reqHeight ) , calculateInSampleSizeByMaxTextureSize ( options . outWidth , options . outHeight ) ) ; Bitmap bitmap = decodeImage ( resolver , uri , options ) ; return new DecodeBitmapResult ( bitmap , options . inSampleSize ) ; } catch ( Exception e ) { throw new RuntimeException ( "Failed to load sampled bitmap: " + uri + "\r\n" + e . getMessage ( ) , e ) ; } }
decode bitmap from stream using sampling to get bitmap with the requested limit .
