You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ImageUtils的getBitmap(final InputStream is, final int maxWidth, final int maxHeight)方法有OOM的风险。
其他的getBitmap有限制maxWidth和maxHeight的方法,均是先设置options.inJustDecodeBounds = true不加载到内存获取图片宽高,再计算压缩比例的方式。
唯独处理InputStream的方法,在限制maxWidth和maxHeight时,是先将InputStream转化成byte[],再计算压缩比例,这一步,图片数据已经加载到内存,如果是一张非常大的图片,是有OOM的风险的。
为何不同样先设置options.inJustDecodeBounds = true获取宽高,再通过BitmapFactory.decodeStream(input, null, bitmapOptions)来压缩图片?