Closed ybADMIN closed 7 years ago
你的图片多大
这个问题已经解决了,原因是因为原图编码有些问题,重新编码就能解决,不过出现另一个问题 Bitmap too large to be uploaded into a texture (440x4431, max=4096x4096)
//加载完整图片的缩略图
try {
int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
int screenHeight = context.getResources().getDisplayMetrics().heightPixels;
int s = (int) Math.sqrt(1.0f * imageWidth * imageHeight / (screenWidth / 2) / (screenHeight / 2));
cacheImageScale = getNearScale(s);
if (cacheImageScale < s) {
cacheImageScale *= 2;
}
loadData.handler.sendMessage(loadData.handler.obtainMessage(MESSAGE_PIC, cacheImageScale));
} catch (Exception e) {
e.printStackTrace();
}
}
应该是这块代码中 getNearScale(s)计算有问题 图片计算后s值为1 getNearScale(s);得到的值也是1
因此会抛出
Bitmap too large to be uploaded into a texture (440x4431, max=4096x4096)
建议向上取整:
(int) Math.sqrt(1.0f * imageWidth * imageHeight / (screenWidth / 2) / (screenHeight / 2));
改为
int s = (int) Math.sqrt(Math.ceil(1.0f * imageWidth * imageHeight / (screenWidth / 2) / (screenHeight / 2)));
那你解码后的图片是 http://short.im.rockhippo.cn/uploads/msg/201703/20170309/1485/1489068660846.jpg这个么? 还是解码前的 问题应该不在getNearScale(s),因为s为1,说明图片要显示的不缩放的
调试了下本来缩放scale 1.9392987 结果(int)后变1,确定是你说的那个原因
scale 1.9392987 结果(int)后变1 如果是不缩放的话就会 Bitmap too large to be uploaded into a texture (440x4431, max=4096x4096) 你没有遇到这个问题?
已处理