BitmapAsyncTask--getSampleBitmap--return BitmapFactory.decodeStream(stream, null, options);为null
bingducaijun opened this issue · comments
bingducaijun commented
/**
*
* @param is 第二次压缩容易为空
* @param width
* @param height
* @return
*/
private Bitmap getSampleBitmap(InputStream is, int width, int height)
{
BufferedInputStream stream = new BufferedInputStream(is);
stream.mark(4 * 1024);
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(stream, null, options);
calculateInSampleSize(width, height, options, true);
try
{
stream.reset();
} catch (IOException e)
{
}
return BitmapFactory.decodeStream(stream, null, options);
}
建议修改一下:
private Bitmap getSampleBitmap2(byte[] data, int width, int height)
{
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeByteArray(data, 0, data.length, options);
calculateInSampleSize(width, height, options, true);
return BitmapFactory.decodeByteArray(data, 0, data.length, options);
}
xyzlf commented
嗯嗯,执行过程中,没遇到过。你遇到过null异常么?
xyzlf commented
你可以多验证下,如果工程中的确实有问题,你这个比较稳定,可以提个分支,我给你合进来~