0
我從網址下載圖片並顯示在我的android應用程序中,但我無法根據我的要求調整圖片大小。Android Image Resizing
private Bitmap decodeFile(File f) {
try {
//Decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
FileInputStream stream1 = new FileInputStream(f);
BitmapFactory.decodeStream(stream1, null, o);
stream1.close();
//Find the correct scale value. It should be the power of 2.
// Set width/height of recreated image
final int REQUIRED_SIZE = 285;
int width_tmp = o.outWidth, height_tmp = o.outHeight;
int scale = 1;
while (true) {
if (width_tmp/2 < REQUIRED_SIZE || height_tmp/2 < REQUIRED_SIZE)
break;
width_tmp /= 1;
height_tmp /= 1;
scale *= 2;
}
//decode with current scale values
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize = scale;
FileInputStream stream2 = new FileInputStream(f);
Bitmap bitmap = BitmapFactory.decodeStream(stream2, null, o2);
stream2.close();
return bitmap;
} catch (FileNotFoundException e) {
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
現在任何一個可以告訴我,我怎麼能調整我的圖像250 * 250像素 也感謝名單提前
「我無法根據我的要求調整圖像大小」 - 請編輯您的問題並詳細解釋**,詳細說明**,您的問題是什麼。 **具體**不適用於您嘗試過的代碼? – CommonsWare