BitmapFactory.Options options=new BitmapFactory.Options();
options.inJustDecodeBounds=true;
BitmapFactory.decodeResource(getResources(),R.mipmap.bitmap,options);
int outHeight = options.outHeight;
int outWidth = options.outWidth;
Log.d(TAG,"outHeight == >"+outHeight);
Log.d(TAG,"outWidth == >"+outWidth);
int measuredHeight = result_image.getMeasuredHeight();
int measuredWidth = result_image.getMeasuredWidth();
Log.d(TAG,"measureHeight ==>"+measuredHeight);
Log.d(TAG,"measureWidth ==>"+measuredWidth);
options.inSampleSize=1;
if (outHeight>measuredHeight||outWidth>measuredWidth){
int subHeight = outHeight / measuredHeight;
int subWidth = outWidth / measuredWidth;
options.inSampleSize=subHeight>subWidth?subWidth : subHeight;
}
options.inJustDecodeBounds=false;
Log.d(TAG,"options.inSampleSize==>"+options.inSampleSize);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.bitmap, options);
result_image.setImageBitmap(bitmap);