位图大小超过VM预算"&QUOT - 当负荷图像错误 [英] Error when load image - "Bitmap size exceeds VM budget"

查看:104
本文介绍了位图大小超过VM预算"&QUOT - 当负荷图像错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不断收到这个错误,错误指向这个code:

I keep getting this error and the error point to this code:

=位BitmapFactory.de codeByteArray的(PIC1,0,pic1.length);

bitmap = BitmapFactory.decodeByteArray(pic1 , 0, pic1.length);

图片是从SQLite数据库,存储的用户后,选择目录中的手机图片。
当我要检索的图片,我得到了错误。
从我的阅读,这是因为内存泄漏。
任何建议/解决方案?

the picture is from the sqlite database, stored after user select the picture from directory in phone. when i want to retrieve the picture, i got the error. from my reading, it is because the memory leak. Any suggestion/solution?

更新

问题解决了,当我下面添加前code中的图像保存到数据库中。

The problem solve when I add the code below before save the image into database.

BitmapFactory.Options选择=新BitmapFactory.Options();

BitmapFactory.Options opt = new BitmapFactory.Options();

opt.inSampleSize = 8;

opt.inSampleSize = 8;

=位BitmapFactory.de codeFILE(路径选择);

bitmap = BitmapFactory.decodeFile(path,opt);

感谢那些谁回答/答案:)

Thanks for those who reply/answer :)

推荐答案

试试这个

BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inTempStorage = new byte[16*1024];

Bitmap bitmapImage = BitmapFactory.decodeFile(imgpath, opt);

这篇关于位图大小超过VM预算"&QUOT - 当负荷图像错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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