Skip to content

Commit cb23f4e

Browse files
committed
see 10/25 log
1 parent 85fce6c commit cb23f4e

File tree

5 files changed

+29
-13
lines changed

5 files changed

+29
-13
lines changed

README-CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ getComments : 获取压缩文件中的注释链表
612612

613613
Gradle:
614614
``` groovy
615-
compile 'com.blankj:utilcode:1.9.4'
615+
compile 'com.blankj:utilcode:1.9.5'
616616
```
617617

618618

@@ -635,7 +635,7 @@ Utils.init(application);
635635

636636
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
637637

638-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.4-brightgreen.svg
638+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.5-brightgreen.svg
639639
[auc]: https://github.com/Blankj/AndroidUtilCode
640640

641641
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ getComments
612612

613613
Gradle:
614614
``` groovy
615-
compile 'com.blankj:utilcode:1.9.4'
615+
compile 'com.blankj:utilcode:1.9.5'
616616
```
617617

618618

@@ -635,7 +635,7 @@ Utils.init(application);
635635

636636
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
637637

638-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.4-brightgreen.svg
638+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.5-brightgreen.svg
639639
[auc]: https://github.com/Blankj/AndroidUtilCode
640640

641641
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ ext {
2929
minSdkVersion = 14
3030
targetSdkVersion = 22
3131

32-
versionCode = 100900400
33-
versionName = '1.9.4'
32+
versionCode = 100900500
33+
versionName = '1.9.5'
3434

3535
// App dependencies
3636
supportVersion = '25.3.1'

update_log.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* 17/10/25 修复LogUtils边框
1+
* 17/10/25 修复LogUtils边框,修复getBitmap从流获取
22
* 17/09/30 完善FragmentUtils,发布1.9.2
33
* 17/09/29 完善FragmentUtils和isInstallApp
44
* 17/09/28 完善FragmentUtils

utilcode/src/main/java/com/blankj/utilcode/util/ImageUtils.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import android.support.v4.content.ContextCompat;
3636
import android.view.View;
3737

38+
import com.blankj.utilcode.constant.MemoryConstants;
39+
3840
import java.io.BufferedOutputStream;
3941
import java.io.ByteArrayOutputStream;
4042
import java.io.File;
@@ -240,12 +242,8 @@ public static Bitmap getBitmap(final InputStream is) {
240242
*/
241243
public static Bitmap getBitmap(final InputStream is, final int maxWidth, final int maxHeight) {
242244
if (is == null) return null;
243-
BitmapFactory.Options options = new BitmapFactory.Options();
244-
options.inJustDecodeBounds = true;
245-
BitmapFactory.decodeStream(is, null, options);
246-
options.inSampleSize = calculateInSampleSize(options, maxWidth, maxHeight);
247-
options.inJustDecodeBounds = false;
248-
return BitmapFactory.decodeStream(is, null, options);
245+
byte[] bytes = input2Byte(is);
246+
return getBitmap(bytes, 0, maxWidth, maxHeight);
249247
}
250248

251249
/**
@@ -1776,4 +1774,22 @@ private static int calculateInSampleSize(final BitmapFactory.Options options,
17761774
}
17771775
return inSampleSize;
17781776
}
1777+
1778+
private static byte[] input2Byte(final InputStream is) {
1779+
if (is == null) return null;
1780+
try {
1781+
ByteArrayOutputStream os = new ByteArrayOutputStream();
1782+
byte[] b = new byte[MemoryConstants.KB];
1783+
int len;
1784+
while ((len = is.read(b, 0, MemoryConstants.KB)) != -1) {
1785+
os.write(b, 0, len);
1786+
}
1787+
return os.toByteArray();
1788+
} catch (IOException e) {
1789+
e.printStackTrace();
1790+
return null;
1791+
} finally {
1792+
CloseUtils.closeIO(is);
1793+
}
1794+
}
17791795
}

0 commit comments

Comments
 (0)