判断图的长度是否过长,如果过长需要使用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;
}

你可能感兴趣的:(webView)