我有非常大的位圖圖像。我的源如何將位圖的大小調整爲最大可用大小?
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(例如)
問題被關閉,HTTP:// stackoverflow.com/a/7523221/1568164 - answer –