android图片分辨率改变,在Android应用中更改位图分辨率
您可以设置其宽度和高度Bitmap bm = ShrinkBitmap(imagefile, 150, 150);通话功能Bitmap ShrinkBitmap(String file, int width, int height){BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();bmpFactoryOpt
您可以设置其宽度和高度
Bitmap bm = ShrinkBitmap(imagefile, 150, 150);
通话功能
Bitmap ShrinkBitmap(String file, int width, int height){
BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();
bmpFactoryOptions.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeFile(file, bmpFactoryOptions);
int heightRatio = (int)Math.ceil(bmpFactoryOptions.outHeight/(float)height);
int widthRatio = (int)Math.ceil(bmpFactoryOptions.outWidth/(float)width);
if (heightRatio > 1 || widthRatio > 1)
{
if (heightRatio > widthRatio)
{
bmpFactoryOptions.inSampleSize = heightRatio;
} else {
bmpFactoryOptions.inSampleSize = widthRatio;
}
}
bmpFactoryOptions.inJustDecodeBounds = false;
bitmap = BitmapFactory.decodeFile(file, bmpFactoryOptions);
return bitmap;
}
}
这是另外两个可能对您有帮助的链接. Link 1及以上Link 2
更多推荐
所有评论(0)