加载一个 尺寸特别大的图 6000*4000*4 多的一个图;造成 绘制 时候 系统崩了,这是一张140Mb和一张200Mb的图
|
|
java.lang.RuntimeException:
Canvas:
trying to draw too large(213828900bytes)
bitmap.java.lang.RuntimeException:
Canvas:
trying to draw too large(112265312bytes)
bitmap.尝试用使用如下方法就可以解决了
Bitmap image = BitmapFactory.decodeFile(file.getPath());//loading the large bitmap is fine. int w = image.getWidth();//get widthint h = image.getHeight();//get heightint aspRat = w / h;//get aspect ratioint W = [handle width management here...];//do whatever
you want with width. Fixed, screen size, anythingint H = w * aspRat;//set the height based on width and aspect ratio
Bitmap b = Bitmap.createScaledBitmap(image, W, H, false);//scale the bitmapimageView.setImageBitmap(b);//set the image viewimage = null;//save memory on the bitmap called 'image'
处理大尺寸图片导致的Canvas异常
在尝试绘制尺寸为6000*4000且颜色深度为4的大型图片时,遇到了java.lang.RuntimeException: Canvas:trying to draw too large的错误,导致系统崩溃。问题涉及到140Mb和200Mb的两张图片。
1万+

被折叠的 条评论
为什么被折叠?



