ImageUtils.java
803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.people.basemusic.utils;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2016/08/12
* desc : utils about image
* </pre>
*/
public final class ImageUtils {
/**
* Return bitmap.
*
* @param filePath The path of file.
* @return bitmap
*/
public static Bitmap getBitmap(final String filePath) {
if (isSpace(filePath)) {
return null;
}
return BitmapFactory.decodeFile(filePath);
}
private static boolean isSpace(final String s) {
if (s == null) {
return true;
}
for (int i = 0, len = s.length(); i < len; ++i) {
if (!Character.isWhitespace(s.charAt(i))) {
return false;
}
}
return true;
}
}