Canvas:试图在android.view.DisplayListCanvas.throwIfCannotDraw中绘制太大(144609280bytes)的位图

问题描述 投票:0回答:1

我从Web服务获取图像,我会在imageView中显示它。

Picasso.with(getApplicationContext()).load(imageURL).fit().centerCrop().into(ivNews);

2天前2048X1600分辨率图像上传到服务器上,所有突发的应用程序开始崩溃与此例外Canvas: trying to draw too large(144609280bytes) bitmap

上传到服务器上的图像可能高于上述分辨率,服务器也可以在将来上传更多高分辨率图像。

我读过this文章,它提到glide在性能方面比毕加索更快更好

它还提到,如果你使用,.fit().centerCrop()然后性能更好,但我已经使用这些,并得到这些错误消息

我想用毕加索来解决这个问题

android android-layout picasso android-glide
1个回答
4
投票

如果图像尺寸较大,您可以使用scaleDown()来缩放图像。您可以像下面一样使用它。

Picasso  
.with(context)
.load(<image_url>)
.resize(2048, 1600)
.onlyScaleDown() // the image will only be resized if it's bigger than 2048x 1600 pixels.
.into(<image_view>);
© www.soinside.com 2019 - 2024. All rights reserved.