Skip to content

Instantly share code, notes, and snippets.

@unclechen
Created March 4, 2016 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unclechen/547ff2d71b39dc472b98 to your computer and use it in GitHub Desktop.
Save unclechen/547ff2d71b39dc472b98 to your computer and use it in GitHub Desktop.
BitmapUtil
/**
* 检查图片是否损坏:通过指定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