画布:尝试在android.view.DisplayListCanvas.throwIfCannotDraw处绘制太大(144609280字节)的位图 [英] Canvas: trying to draw too large(144609280bytes) bitmap, at android.view.DisplayListCanvas.throwIfCannotDraw

查看:796
本文介绍了画布:尝试在android.view.DisplayListCanvas.throwIfCannotDraw处绘制太大(144609280字节)的位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Web服务获取图像,我遵循以下步骤将其显示在imageView中.

I get image from a web service, i do following to display it in imageView.

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

2天前,一个2048X1600分辨率图像已上传到服务器上,并且所有突然的应用程序因该异常Canvas: trying to draw too large(144609280bytes) bitmap

2 days ago a 2048X1600 resolution images was uploaded on server, and all of sudden app start crashing with this exception Canvas: trying to draw too large(144609280bytes) bitmap

服务器上上传的图像有可能高于上述分辨率,并且服务器将来也可以上传更多高分辨率的图像.

There is a possibility that the image uploaded on server was higher than the mentioned resolution, and server can upload more high resolution images in future as well.

我阅读了这篇文章,它提到glide在性能方面比毕加索更快,更好

I read this article, Its mentioned that glide is faster and better than picasso in terms of performance,

它还提到,如果您使用.fit().centerCrop(),则性能会更好,但是我已经在使用这些,并且收到了这些错误消息

It also mentioned that if you use, .fit().centerCrop() then the performance is better, but i was already using these, and got these error message

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

I want to solve this by using picasso

推荐答案

如果图像较大,则可以使用scaleDown()缩放图像.您可以像下面那样使用它.

You could use scaleDown() to scale the image if it is of bigger size. You could use it like below.

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>);

这篇关于画布:尝试在android.view.DisplayListCanvas.throwIfCannotDraw处绘制太大(144609280字节)的位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆