さて、画像をダウンロードしてこのメソッドに入力ストリームを送信します。魔女は画像サイズを見つけるために一度デコードし、スケール値を計算してから、ストリームからビットマップのミニバージョンを作成する必要があります。ビットマップファクトリーがnullを返していることをlogcat、誰かが何が間違っている可能性があるか考えていますか?
public static Bitmap getSampleBitmapFromStream(InputStream is,
int reqWidth, int reqHeight) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(new FlushedInputStream(is), null, options);
// Find the correct scale value. It should be the power of 2.
int width_tmp = options.outWidth, height_tmp = options.outHeight;
int scale = 1;
while (true) {
if (width_tmp / 2 < reqWidth || height_tmp / 2 < reqHeight)
break;
width_tmp /= 2;
height_tmp /= 2;
scale *= 2;
}
// decode with inSampleSize
options.inJustDecodeBounds = false;
options.inSampleSize = scale;
return BitmapFactory.decodeStream(new FlushedInputStream(is), null, options);
}