Skip to content

Commit

Permalink
解决微信分享图片偶现图片被回收问题
Browse files Browse the repository at this point in the history
  • Loading branch information
liujinwei committed Apr 15, 2019
1 parent d1f7636 commit bb052f1
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,29 @@ static byte[] bmpToByteArray(final Bitmap bmp, boolean needThumb) {
height = 150;
}
newBmp = Bitmap.createScaledBitmap(bmp, width, height, true);
bmp.recycle();
} else {
newBmp = bmp;
}
ByteArrayOutputStream output = new ByteArrayOutputStream();
newBmp.compress(Bitmap.CompressFormat.JPEG, 100, output);
newBmp.recycle();

byte[] result = output.toByteArray();
try {
output.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (!bmp.isRecycled()) {
bmp.recycle();
}
if (!newBmp.isRecycled()) {
newBmp.recycle();
}
}

return result;
}

/**
* 是否安装qq
*/
Expand Down

0 comments on commit bb052f1

Please sign in to comment.