毕加索不加载大图像



我正在使用库Picasso下载图像。对于小图像,它工作得很好,但对于 1.5Mb 或更多的图像,调用方法onBitmapFailed并且不显示图像。我是这样做的:

final int shortestSide = Math.min(image.getHeight(), image.getWidth());
final int longestSideView = Math.max(getAvailableHeight(), getAvailableWidth());
final float picassoScale = (float) longestSideView / (float) shortestSide;
final int widthWithoutExif;
final int heightWithoutExif;
final int exifRotation = Util.mod(image.getExifOrientation(), 360);
switch (exifRotation){
case 90:
case 270:
widthWithoutExif = image.getHeight();
heightWithoutExif = image.getWidth();
break;
default:
widthWithoutExif = image.getWidth();
heightWithoutExif = image.getHeight();
}
final RequestCreator requestCreator;
requestCreator = picasso.load(new File(cacheFilePath()));
requestCreator.resize((int) (widthWithoutExif * picassoScale), (int) (heightWithoutExif * picassoScale));
requestCreator.into(this);

有人知道我错过了什么吗?提前感谢!

编辑这是堆栈跟踪:

java.io.IOException: Cannot reset
04-25 14:20:30.225 26278-26278/debug W/System.err:     at        com.squareup.picasso.MarkableInputStream.reset(MarkableInputStream.java:99)
04-25 14:20:30.225 26278-26278/debug W/System.err:     at com.squareup.picasso.BitmapHunter.decodeStream(BitmapHunter.java:140)
04-25 14:20:30.225 26278-26278/debug W/System.err:     at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:217)
04-25 14:20:30.225 26278-26278/debug W/System.err:     at    com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:159)
04-25 14:20:30.225 26278-26278/debug W/System.err:     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
04-25 14:20:30.225 26278-26278/debug W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
04-25 14:20:30.225 26278-26278/debug W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
04-25 14:20:30.225 26278-26278/debug W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
04-25 14:20:30.225 26278-26278/debug W/System.err:     at java.lang.Thread.run(Thread.java:818)
04-25 14:20:30.225 26278-26278/debug W/System.err:     at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:411)

最后我发现这是一个Picasso错误。问题的链接。通过升级到 2.5.3-快照来修复此问题。

最新更新