Android—压缩图片,减少内存
2015-08-26 10:02
471 查看
private BitmapDrawable setBimap(int resId){
BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inPreferredConfig = Bitmap.Config.RGB_565;
opt.inPurgeable = true;
opt.inInputShareable = true;
//获取资源图片
InputStream is = HelpPagerFragment.this.getActivity().getResources().openRawResource(resId);
Bitmap bitmap = BitmapFactory.decodeStream(is,null, opt);
try {
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new BitmapDrawable(mContext.getResources(),bitmap);
}
使用
view = inflater.inflate(R.layout.helppage5, container, false);
view.setBackgroundDrawable(setBimap(R.drawable.helppage5));
原文地址:http://jingyan.baidu.com/article/ed2a5d1f3191d109f6be17e8.html
BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inPreferredConfig = Bitmap.Config.RGB_565;
opt.inPurgeable = true;
opt.inInputShareable = true;
//获取资源图片
InputStream is = HelpPagerFragment.this.getActivity().getResources().openRawResource(resId);
Bitmap bitmap = BitmapFactory.decodeStream(is,null, opt);
try {
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new BitmapDrawable(mContext.getResources(),bitmap);
}
使用
view = inflater.inflate(R.layout.helppage5, container, false);
view.setBackgroundDrawable(setBimap(R.drawable.helppage5));
原文地址:http://jingyan.baidu.com/article/ed2a5d1f3191d109f6be17e8.html
相关文章推荐
- php实现批量压缩图片文件大小的脚本
- angularjs客户端实现压缩图片文件并上传实例
- java实现上传图片并压缩图片大小功能
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- PHP压缩上传图片
- Android如何实现压缩图片后再上传至服务器
- Java图片上传压缩处理
- JAVA 压缩图片-解析一维码二维码-ZXING
- C# 压缩PDF图片
- 根据路径获取图片,缩放图片
- 根据图片路径压缩图片并返回压缩后图片的路径
- 压缩图片尺寸
- 微信截屏分享、图片压缩处理!
- iOS微信截屏分享
- Android中利用Picasso实现图片压缩指定任意尺寸
- Fresco按照宽高压缩图片的方法
- Thumbnailator图像处理
- android调用系统照相机拍照,并压缩保存在本地
- Jquery+HTML5+PHP实现前台压缩图片并上传
- Android高效压缩图片不失真的方法总结