Canvas: trying to draw too large(144609280bytes) bitmap, at android.view.DisplayListCanvas.throwIfCannotDraw

不打扰是莪最后的温柔 提交于 2019-12-20 06:47:04

问题


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 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.

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

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


回答1:


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


来源:https://stackoverflow.com/questions/48863447/canvas-trying-to-draw-too-large144609280bytes-bitmap-at-android-view-display

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!