Created
March 4, 2016 08:45
-
-
Save unclechen/547ff2d71b39dc472b98 to your computer and use it in GitHub Desktop.
BitmapUtil
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 检查图片是否损坏:通过指定inJustDecodeBounds = true来得到解析图片以后的Options | |
* | |
* @param filePath | |
* @return | |
*/ | |
public static boolean checkImgDamage(String filePath) { | |
BitmapFactory.Options options = null; | |
if (options == null) { | |
options = new BitmapFactory.Options(); | |
} | |
options.inJustDecodeBounds = true; | |
BitmapFactory.decodeFile(filePath, options); | |
if (options.mCancel || options.outWidth == -1 || options.outHeight == -1) { | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment