bitmap总结
来源:互联网 发布:sql 字段去重复查询 编辑:程序博客网 时间:2024/06/14 16:40
图片过大,加载到内存出现OOM异常,上传到网络耗费大量浏览,所以需要压缩。
压缩分为尺寸压缩和质量压缩:尺寸压缩解决内存问题,质量压缩解决外存问题。
1、尺寸压缩
占用内存=图片宽度 X 图片高度/((资源文件夹密度(inDensity)/手机屏幕密度(inTargetDensity))^2) * 色彩格式每一个像素占用字节数(inPreferredConfig)。
图片存放位置有:drawable、asset、raw、src、sdcard/网络。通常我们只需要考虑inSampleSize(2的N次方)参数进行采样率压缩。
针对drawable图片,还需要考虑inScaled参数,inScaled = inTargetDensity/inDensity。
2、质量压缩
Bitmap的compress方法:
image.compress(Bitmap.CompressFormat.JPEG, 50, os);//这里压缩50%,把压缩后的数据存放到baos中
参考:
http://blog.csdn.net/u012861467/article/details/52013795
http://blog.csdn.net/smileiam/article/details/68946182
http://blog.csdn.net/buaaroid/article/details/50563982
阅读全文
0 0
- Bitmap---Bitmap用法总结
- Bitmap总结
- Bitmap总结
- Bitmap总结
- bitmap总结
- bitmap 常用总结
- android Bitmap用法总结
- android Bitmap学习总结
- android Bitmap学习总结
- android Bitmap用法总结
- android Bitmap总结
- Android Bitmap用法总结
- android Bitmap学习总结
- android Bitmap用法总结
- android Bitmap用法总结
- Android Bitmap用法总结
- android Bitmap用法总结
- android Bitmap用法总结
- Hanoi Tower Troubles Again! ZOJ
- NLP中的语言模型(language model)
- 兰州银行扫码取款1天被叫停,金融创新需要合规
- Web漏扫工具一览表
- unicode转中文
- bitmap总结
- 检测浏览器,平台,系统js
- 乌鲁木齐网赛I-island-tarjan
- Laravel 5.5快速搭建博客api系统-1
- UVAlive 3602 DNA序列(计数+瞎搞)
- Android开发常用的设计模式
- Android使用tools预览布局,发布的时候会自动关闭预览数据
- 【安全牛学习笔记】主动信息收集-发现
- Android知识点整理(三)