LuckyJayce / LargeImage

Android 加载大图 可以高清显示10000*10000像素的图片,轻松实现微博长图功能
Apache License 2.0
2.33k stars 416 forks source link

图片无法解码 #18

Closed ybADMIN closed 7 years ago

ybADMIN commented 7 years ago

03-08 10:43:05.672 809-1142/com.huanmedia.yourchum.debug D/ONE SDK: [2017/3/8 10:43:5:679]: [net] has wifi connection
03-08 10:43:05.672 809-14006/com.huanmedia.yourchum.debug W/System.err:     at android.graphics.BitmapRegionDecoder.nativeNewInstance(Native Method)
03-08 10:43:05.672 809-14006/com.huanmedia.yourchum.debug W/System.err:     at android.graphics.BitmapRegionDecoder.newInstance(BitmapRegionDecoder.java:124)
03-08 10:43:05.682 809-14006/com.huanmedia.yourchum.debug W/System.err:     at android.graphics.BitmapRegionDecoder.newInstance(BitmapRegionDecoder.java:150)
03-08 10:43:05.682 809-14006/com.huanmedia.yourchum.debug W/System.err:     at com.shizhefei.view.largeimage.factory.FileBitmapDecoderFactory.made(FileBitmapDecoderFactory.java:23)
03-08 10:43:05.682 809-14006/com.huanmedia.yourchum.debug W/System.err:     at com.shizhefei.view.largeimage.BlockImageLoader$LoadHandler.handleMessage(BlockImageLoader.java:805)
03-08 10:43:05.692 809-14006/com.huanmedia.yourchum.debug W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
03-08 10:43:05.692 809-14006/com.huanmedia.yourchum.debug W/System.err:     at android.os.Looper.loop(Looper.java:136)
03-08 10:43:05.692 809-14006/com.huanmedia.yourchum.debug W/System.err:     at android.os.HandlerThread.run(HandlerThread.java:61)
LuckyJayce commented 7 years ago

你的图片多大

ybADMIN commented 7 years ago

这个问题已经解决了,原因是因为原图编码有些问题,重新编码就能解决,不过出现另一个问题 Bitmap too large to be uploaded into a texture (440x4431, max=4096x4096)

ybADMIN commented 7 years ago

http://short.im.rockhippo.cn/uploads/msg/201703/20170309/1485/1489068660846.jpg

ybADMIN commented 7 years ago

            //加载完整图片的缩略图
            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)));
LuckyJayce commented 7 years ago

那你解码后的图片是 http://short.im.rockhippo.cn/uploads/msg/201703/20170309/1485/1489068660846.jpg这个么? 还是解码前的 问题应该不在getNearScale(s),因为s为1,说明图片要显示的不缩放的

LuckyJayce commented 7 years ago

调试了下本来缩放scale 1.9392987 结果(int)后变1,确定是你说的那个原因

ybADMIN commented 7 years ago

scale 1.9392987 结果(int)后变1 如果是不缩放的话就会 Bitmap too large to be uploaded into a texture (440x4431, max=4096x4096) 你没有遇到这个问题?

LuckyJayce commented 7 years ago

已处理