public static Bitmap decodeSampledBitmapFromResource(Resources resources,int resId,int reqWidth,int reqHeight){
  final BitmapFactory.Options options=new BitmapFactory.Options();
  options.inJustDecodeBounds=true;
  BitmapFactory.decodeResource(resources,resId,options);
  options.inSampleSize=calculateInSampleSize(options,reqWidth,reqHeight);
  options.inJustDecodeBounds=false;
  return BitmapFactory.decodeResource(resources,resId,options);
}

public static Bitmap decodeSampledBitmapFromResource ( Resources resources , int resId , int reqWidth , int reqHeight ) { final BitmapFactory . Options options = new BitmapFactory . Options ( ) ; options . inJustDecodeBounds = true ; BitmapFactory . decodeResource ( resources , resId , options ) ; options . inSampleSize = calculateInSampleSize ( options , reqWidth , reqHeight ) ; options . inJustDecodeBounds = false ; return BitmapFactory . decodeResource ( resources , resId , options ) ; }
decode a resource to bitmap width sample size .
