`
程言方
  • 浏览: 46806 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

判断图的长度是否过长,如果过长需要使用webView加载

 
阅读更多
public static boolean isThisBitmapTooLargeToRead(String path) {

File file = new File(path);

if (!file.exists()) {
return false;
}

final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, options);
int width = options.outWidth;
int height = options.outHeight;
if (width == -1 || height == -1) {
return false;
}

if (width >getBitmapMaxWidthAndMaxHeight()
|| height >getBitmapMaxWidthAndMaxHeight()) {
return true;
} else {
return false;
}
}

public static int getBitmapMaxWidthAndMaxHeight() {
int[] maxSizeArray = new int[1];
GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);

if (maxSizeArray[0] == 0) {
GLES10.glGetIntegerv(GL11.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);
}
// return maxSizeArray[0];
return 2048;
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics