diff --git a/README-CN.md b/README-CN.md index a9f0be59dc1604808e946f15525330471897f55d..c8eed210df13cb7b2a6312de6ae3abb4bbffec5a 100644 --- a/README-CN.md +++ b/README-CN.md @@ -612,7 +612,7 @@ getComments : 获取压缩文件中的注释链表 Gradle: ``` groovy -compile 'com.blankj:utilcode:1.9.4' +compile 'com.blankj:utilcode:1.9.5' ``` @@ -635,7 +635,7 @@ Utils.init(application); [logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png -[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.4-brightgreen.svg +[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.5-brightgreen.svg [auc]: https://github.com/Blankj/AndroidUtilCode [apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg diff --git a/README.md b/README.md index f15c2edf35e187adadbd72834286105245eccd3c..356e2073404bd11eec541dbfce2fad92e1e17ab0 100644 --- a/README.md +++ b/README.md @@ -612,7 +612,7 @@ getComments Gradle: ``` groovy -compile 'com.blankj:utilcode:1.9.4' +compile 'com.blankj:utilcode:1.9.5' ``` @@ -635,7 +635,7 @@ Utils.init(application); [logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png -[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.4-brightgreen.svg +[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.5-brightgreen.svg [auc]: https://github.com/Blankj/AndroidUtilCode [apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg diff --git a/build.gradle b/build.gradle index 76ae503dd267c0f40fae3201088ae5b85e3b5444..bd6dbda700378e8631d72357271ac7d093acc3fb 100644 --- a/build.gradle +++ b/build.gradle @@ -29,8 +29,8 @@ ext { minSdkVersion = 14 targetSdkVersion = 22 - versionCode = 100900400 - versionName = '1.9.4' + versionCode = 100900500 + versionName = '1.9.5' // App dependencies supportVersion = '25.3.1' diff --git a/update_log.md b/update_log.md index c4352411316e341b0d1fa16f3289a4df6166f212..84adab46d597d7ae2a02fd1da1edd603353f4ff6 100644 --- a/update_log.md +++ b/update_log.md @@ -1,4 +1,4 @@ -* 17/10/25 修复LogUtils边框 +* 17/10/25 修复LogUtils边框,修复getBitmap从流获取 * 17/09/30 完善FragmentUtils,发布1.9.2 * 17/09/29 完善FragmentUtils和isInstallApp * 17/09/28 完善FragmentUtils diff --git a/utilcode/src/main/java/com/blankj/utilcode/util/ImageUtils.java b/utilcode/src/main/java/com/blankj/utilcode/util/ImageUtils.java index f3e669280b393f28c4542f4614dea0e157ded284..795802d969dd6913851040ca4fd5022fb626e9b6 100644 --- a/utilcode/src/main/java/com/blankj/utilcode/util/ImageUtils.java +++ b/utilcode/src/main/java/com/blankj/utilcode/util/ImageUtils.java @@ -35,6 +35,8 @@ import android.support.annotation.IntRange; import android.support.v4.content.ContextCompat; import android.view.View; +import com.blankj.utilcode.constant.MemoryConstants; + import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -240,12 +242,8 @@ public final class ImageUtils { */ public static Bitmap getBitmap(final InputStream is, final int maxWidth, final int maxHeight) { if (is == null) return null; - BitmapFactory.Options options = new BitmapFactory.Options(); - options.inJustDecodeBounds = true; - BitmapFactory.decodeStream(is, null, options); - options.inSampleSize = calculateInSampleSize(options, maxWidth, maxHeight); - options.inJustDecodeBounds = false; - return BitmapFactory.decodeStream(is, null, options); + byte[] bytes = input2Byte(is); + return getBitmap(bytes, 0, maxWidth, maxHeight); } /** @@ -1776,4 +1774,22 @@ public final class ImageUtils { } return inSampleSize; } + + private static byte[] input2Byte(final InputStream is) { + if (is == null) return null; + try { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + byte[] b = new byte[MemoryConstants.KB]; + int len; + while ((len = is.read(b, 0, MemoryConstants.KB)) != -1) { + os.write(b, 0, len); + } + return os.toByteArray(); + } catch (IOException e) { + e.printStackTrace(); + return null; + } finally { + CloseUtils.closeIO(is); + } + } }