关于bitmap内存溢出的问题

lytlwhl 2014-09-05 02:59:42
Bitmap Bm = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getAbsolutePath() + "/id4.jpg");
int mBitmapWidth = Bm.getWidth();
int mBitmapHeight = Bm.getHeight();
int mArrayColorLengh = mBitmapWidth * mBitmapHeight;
int []greyArray =new int[mArrayColorLengh];
Bm.getPixels( greyArray, 0, mBitmapWidth, 0, 0, mBitmapWidth, mBitmapHeight);
执行以上语句后直接报OOM错误,我的图片像素是3328*1872大小,请问有什么解决办法吗?除了用bitmap还有其他类能加载图片并转换为数组来处理的吗?
...全文
142 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
lionfresh 2014-09-05
  • 打赏
  • 举报
回复
引用 2 楼 heaimnmn 的回复:
imgeloader呗
ImageLoader不错
哎,真难 2014-09-05
  • 打赏
  • 举报
回复
imgeloader呗
lionfresh 2014-09-05
  • 打赏
  • 举报
回复

		final BitmapFactory.Options options = new BitmapFactory.Options();
		options.inJustDecodeBounds = true;
		BitmapFactory.decodeFile(fileString, options);
		options.inSampleSize = 16;//缩放的倍数
		options.inJustDecodeBounds = false;
		BitmapFactory.decodeFile(fileName, options);
用这个进行一个缩放,缩放的比例可以根据图片的大小进行缩放。

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧