String imagePath = getIntent().getStringExtra("bitmap_uri");
Display dis = getWindowManager().getDefaultDisplay();
Point size = new Point();
dis.getSize(size);
int windowWidth = size.x;
int windowHeight = size.y;
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inJustDecodeBounds = true;
BitmapFactory.decodeFile(imagePath, opts);
int bitmapHeight = opts.outHeight;
int bitmapWidth = opts.outWidth;
if (bitmapHeight > windowHeight || bitmapWidth > windowWidth) {
int scaleX = bitmapWidth/windowWidth;
int scaleY = bitmapHeight/windowHeight;
if(scaleX>scaleY){//按照水平方向的比例缩放
opts.inSampleSize = scaleX;
}else{//按照竖直方向的比例缩放
opts.inSampleSize = scaleY;
}
}else{//如果图片比手机屏幕小 不去缩放了.
opts.inSampleSize = 1;
}
//让位图工厂真正的去解析图片
opts.inJustDecodeBounds = false;
Bitmap bitmap = BitmapFactory.decodeFile(imagePath, opts);
clipLayout.setImageSource(bitmap);
Display dis = getWindowManager().getDefaultDisplay();
Point size = new Point();
dis.getSize(size);
int windowWidth = size.x;
int windowHeight = size.y;
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inJustDecodeBounds = true;
BitmapFactory.decodeFile(imagePath, opts);
int bitmapHeight = opts.outHeight;
int bitmapWidth = opts.outWidth;
if (bitmapHeight > windowHeight || bitmapWidth > windowWidth) {
int scaleX = bitmapWidth/windowWidth;
int scaleY = bitmapHeight/windowHeight;
if(scaleX>scaleY){//按照水平方向的比例缩放
opts.inSampleSize = scaleX;
}else{//按照竖直方向的比例缩放
opts.inSampleSize = scaleY;
}
}else{//如果图片比手机屏幕小 不去缩放了.
opts.inSampleSize = 1;
}
//让位图工厂真正的去解析图片
opts.inJustDecodeBounds = false;
Bitmap bitmap = BitmapFactory.decodeFile(imagePath, opts);
clipLayout.setImageSource(bitmap);