【发布时间】:2013-02-05 14:55:56
【问题描述】:
我有非常大的位图图像。我的来源
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeStream(new FileInputStream(f), null, o);
// The new size we want to scale to
final int REQUIRED_WIDTH = 1000;
final int REQUIRED_HIGHT = 500;
// Find the correct scale value. It should be the power of 2.
int scale = 1;
while (o.outWidth / scale / 2 >= REQUIRED_WIDTH
&& o.outHeight / scale / 2 >= REQUIRED_HIGHT)
scale *= 2;
// Decode with inSampleSize
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize = scale;
return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
我想正确调整图像大小,我需要将图像调整为最大可用尺寸
例如
我下载的图片大小为 4000x4000 像素,我的手机支持 2000x1500 像素大小 我需要安德斯滕我的手机支持多大尺寸? 然后我将图像大小调整为 2000x1500(例如)
【问题讨论】:
-
问题已结束,stackoverflow.com/a/7523221/1568164 - 回答
标签: android bitmap image-resizing