0
웹 URL에서 이미지를 다운로드하고 내 안드로이드 응용 프로그램에 표시하고 있지만 내 요구 사항에 따라 이미지 크기를 조정할 수 없습니다. http://square.github.io/picasso/ - 안드로이드 이미지 크기 조정
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