Android中图片占用内存的计算
Android中图片占用内存的计算
原文链接 http://blog.sina.com.cn/s/blog_4e60b09d01016133.html
Enum Values | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Bitmap.Config | ALPHA_8 | Each pixel is stored as a single translucency (alpha) channel. This is very useful to efficiently store masks for instance. No color information is stored. With this configuration, each pixel requires 1 byte of memory. 此时图片只有alpha值,没有RGB值,一个像素占用一个字节 |
|||||||||
Bitmap.Config | ARGB_4444 | This field is deprecated. Because of the poor quality of this configuration, it is advised to use ARGB_8888 instead. 这种格式的图片,看起来质量太差,已经不推荐使用。 Each pixel is stored on 2 bytes. The three RGB color channels and the alpha channel (translucency) are stored with a 4 bits precision (16 possible values.) This configuration is mostly useful if the application needs to store translucency information but also needs to save memory. It is recommended to use ARGB_8888 instead of this configuration. 一个像素占用2个字节,alpha(A)值,Red(R)值,Green(G)值,Blue(B)值各占4个bites,共16bites,即2个字节 |
|||||||||
Bitmap.Config | ARGB_8888 | Each pixel is stored on 4 bytes. Each channel (RGB and alpha for translucency) is stored with 8 bits of precision (256 possible values.) This configuration is very flexible and offers the best quality. It should be used whenever possible 一个像素占用4个字节,alpha(A)值,Red(R)值,Green(G)值,Blue(B)值各占8个bites,共32bites,即4个字节 这是一种高质量的图片格式,电脑上普通采用的格式。它也是Android手机上一个BitMap的默认格式。 |
|||||||||
Bitmap.Config | RGB_565 | Each pixel is stored on 2 bytes and only the RGB channels are encoded: red is stored with 5 bits of precision (32 possible values), green is stored with 6 bits of precision (64 possible values) and blue is stored with 5 bits of precision. This configuration can produce slight visual artifacts depending on the configuration of the source. For instance, without dithering, the result might show a greenish tint. To get better results dithering should be applied. This configuration may be useful when using opaque bitmaps that do not require high color fidelity. 一个像素占用2个字节,没有alpha(A)值,即不支持透明和半透明,Red(R)值占5个bites ,Green(G)值占6个bites ,Blue(B)值占5个bites,共16bites,即2个字节.对于没有透明和半透明颜色的图片来说,该格式的图片能够达到比较的呈现效果,相对于ARGB_8888来说也能减少一半的内存开销。因此它是一个不错的选择。另外我们通过android.content.res.Resources来取得一个张图片时,它也是以该格式来构建BitMap的 从Android4.0开始,该选项无效。即使设置为该值,系统任然会采用 ARGB_8888来构造图片 |
透明度 红色 绿色 蓝色
图片格式(Bitmap.Config) |
占用内存的计算方向 |
一张100*100的图片占用内存的大小 |
ALPHA_8 |
图片长度*图片宽度 |
100*100=10000字节 |
ARGB_4444 |
图片长度*图片宽度*2 |
100*100*2=20000字节 |
ARGB_8888 |
图片长度*图片宽度*4 |
100*100*4=40000字节 |
RGB_565 |
图片长度*图片宽度*2 |
100*100*2=20000字节 |
Android中图片占用内存的计算的更多相关文章
- (转)Android中图片占用内存计算
在Android开发中,我现在发现很多人还不会对图片占用内存进行很好的计算.因此撰写该博文来做介绍,期望达到抛砖引玉的作用. Android中一张图片(BitMap)占用的内存主要和以下几个因数有 ...
- 关于Android应用中图片占用内存浅谈
从事过移动端应用开发的童鞋应该都清楚,内存是非常宝贵的资源.如果能很好的利用有限的内存,对应用性能的提升会有很大的帮助.在实际应用开发中图片内存占整个应用非常大的比重,我们只有了解图片是如何加载到内存 ...
- ANDROID开发之OOM:一张图片(BitMap)占用内存的计算 图片内存优化
Android中一张图片(BitMap)占用的内存主要和以下几个因数有关:图片长度,图片宽度,单位像素占用的字节数. 一张图片(BitMap)占用的内存=图片长度*图片宽度*单位像素占用的字节数 注: ...
- 关于Android中图片大小、内存占用与drawable文件夹关系的研究与分析
原文:关于Android中图片大小.内存占用与drawable文件夹关系的研究与分析 相关: Android drawable微技巧,你所不知道的drawable的那些细节 经常会有朋友问我这个问题: ...
- android 图片占用内存与什么有关
android 图片占用内存与什么有关 原文链接:http://blog.csdn.net/zjl5211314/article/details/7041813 在开发手机应用的时候,内存是有限的,那 ...
- Android 中图片压缩分析(上)
作者: shawnzhao,QQ音乐技术团队一员 一.前言 在 Android 中进行图片压缩是非常常见的开发场景,主要的压缩方法有两种:其一是质量压缩,其二是下采样压缩. 前者是在不改变图片尺寸的情 ...
- Android中如何查找内存泄露
1.首先确定是否有内存泄露及哪个程序造成. 1.1.内存泄露已弹出out of memory对话框的情况. 这种情况很简单,直接看对话框就知道是哪个应用的问题了.然后再分析该应用是否是因为内存泄露造成 ...
- Android中常见的内存泄漏
为什么会产生内存泄漏? 当一个对象已经不需要再使用了,本该被回收时,而有另外一个正在使用的对象持有它的引用从而导致它不能被回收,这导致本该被回收的对象不能被回收而停留在堆内存中,这就产生了内存泄漏. ...
- 图片--android 图片占用内存与什么有关
原文链接:http://blog.csdn.net/zjl5211314/article/details/7041813 在开发手机应用的时候,内存是有限的,那使用的时候,就要合理的运用和释放. 那么 ...
随机推荐
- jquery 固定导航
网页代码: <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> & ...
- 经典dp 编辑距离
给定两个字符串S和T,对于T我们可以进行三种操作 (1)在任意位置增加字符 (2)删除字符 (3)替换字符 问最少多少次能把T变成S? 设f(i,j)是S的前i位和T的前j位对齐的最小花费 接下来分析 ...
- amazeui tab 监听当前选项
$('#contenttab').find('a').on('opened.tabs.amui', function(e) { if(e.target.pathname.indexOf("[ ...
- Chapter 16_0 面向对象编程
Lua中的table就是一种对象. 1.table和对象一样拥有状态 2.和对象一样有一个独立的标识符(a self) 3.和对象一样,具有独立于创建者和创建地的生命周期. 对象有他们自己的操作,ta ...
- FreeMarker 小结
一.Sequence 的内置函数1.sequence?first 返回sequence 的第一个值.2.sequence?last 返回sequence 的最后一个值.3.sequence?rever ...
- php 模拟浏览器get和post提交处理
文件夹test下index.php <?phpheader("Content-Type: text/html;charset=gb2312"); function cUrlG ...
- 利用redis做频率限制第一篇
public Result checkRateLimit(String clientIp, int ipTime, int ipCount) { // 每个ip的redis的key都不一样 Strin ...
- zookeeper入门知识
ZooKeeper 是什么? ZooKeeper 顾名思义 动物园管理员,他是拿来管大象(Hadoop) . 蜜蜂(Hive) .小猪(Pig) 的管理员, Apache Hbase和 Apache ...
- 常用的linux系统监控命令整理
找到最耗CPU的java线程ps命令 命令:ps -mp pid -o THREAD,tid,time 或者 ps -Lfp pid 结果展示: 这个命令的作用,主要是可以获取到对应一个进程下的线程的 ...
- Edit Individual GridView Cells in ASP.NET
Edit individual GridView cells without putting the entire row into edit mode.Examples using the SqlD ...