public static Bitmap bytesToBitmap(byte[] b) {
if (b.length != 0) {
return decodeByteArray(b, 0, b.length);
}
return null;
}b的length太大的时候就报错,
图片url http://image.casadellibro.com/a/l/t1/04/9788499672304.jpg
你试一下 如果 lengthch超过 某个限定值 这样写 可行
if(b != null && b.length > 0){
int legth = b.length;
if(legth > 1000){
int legthCount = legth/5;
for(int i = 0 ;i<5;i++){
if((i+1)*lengthCount < legth ){
decodeByteArray(b, i*legthCount, (i+1)*legthCount);
}else{
decodeByteArray(b, i*legthCount,legth );
}
}
}
}
return null;
整体的思路是 :
当b.legth太长时,分成几段进行操作
刚开始我也以为是byte的length太大,后来就把下载的图片的length都打印下来,发现比它还大的下载成功了,最后用pc把图片下载下来,发现是color space的问题,https://www.quora.com/Why-does-the-Android-SKIA-library-have-poor-JPEG-decoding-capabilities,stackoverflow上也是这么说,有人提供了第三方库,但是我还没验证。
感谢你的回复。