//获取文件是否是gif图
public static boolean isGifFile(String picturePath) {
if (!TextUtils.isEmpty(picturePath)) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(picturePath, options);
String type = options.outMimeType;//返回image/gif image/jpeg image/png等
int start = type.lastIndexOf(“/”);//截取类型
String format = “”;
if (start < 0) {
format = type;
} else {
format = type.substring(start + 1);
}
return format.equals(“gif”) || format.equals(“GIF”);
}
return false;
}
Android获取本地相册图片判断是否是gif或png等类型
最新推荐文章于 2023-04-23 00:19:25 发布