q q空间里朋友圈发布文章发布的文章和图片占我的内存吗?

温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
一张图片(BitMap)占用的内存=图片长度*图片宽度*单位像素占用的字节数注:图片长度和图片宽度的单位是像素。图片(BitMap)占用的内存应该和屏幕密度(Density)无关,虽然我暂时还拿不出直接证据。& &创建一个BitMap时,其单位像素占用的字节数由其参数的inPreferredConfig变量决定。inPreferredConfig为类型,类是个枚举类型,它可以为以下值Enum Values&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值,一个像素占用一个字节&ARGB_4444&This field is deprecated. Because of the poor quality of this configuration, it is advised to use&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个字节&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的默认格式。&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来构造图片注:ARGB指的是一种色彩模式,里面A代表Alpha,R表示red,G表示green,B表示blue,其实所有的可见色都是红绿蓝组成的,所以红绿蓝又称为三原色。A  R  G  B透明度 红色 绿色 蓝色简单点说&图片格式()&占用内存的计算方向&一张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字节另外,需要注意这里的图片占用内存是指在Navtive中占用的内存,当然BitMap使用的绝大多数内存就是该内存。因为我们可以简单的认为它就是BitMap所占用的内存。& Bitmap对象在不使用时,我们应该先调用recycle(),然后才它设置为null.虽然Bitmap在被回收时可以通过BitmapFinalizer来回收内存。但是调用recycle()是一个良好的习惯在Android4.0之前,Bitmap的内存是分配在Native堆中,调用recycle()可以立即释放Native内存。从Android4.0开始,Bitmap的内存就是分配在dalvik堆中,即JAVA堆中的,调用recycle()并不能立即释放Native内存。但是调用recycle()也是一个良好的习惯。通过dumpsys meminfo命令可以查看一个进程的内存使用情况,当然也可以通过它来观察我们创建或销毁一张BitMap图片内存的变化,从而推断出图片占用内存的大小。示例:adb shell&"dumpsys&meminfo&com.lenovo.robin"运行结果。Applications Memory Usage (kB):Uptime:
Realtime: ** MEMINFO in pid 7985 [com.lenovo.robin] **& & & & & & & & & &&native&& dalvik & &other & &total& & & & & & size: & & 4828 & & 5379 & & &N/A & &10207& & & &allocated: & & 4073 & & 2852 & & &N/A & & 6925& & & & & & free: & & & 10 & & 2527 & & &N/A & & 2537& & & & & &(Pss): & & &608 & & &317 & & 1603 & & 2528& (shared dirty): & & 2240 & & 1896 & & 6056 & &10192& & (priv dirty): & & &548 & & & 36 & & 1276 & & 1860&Objects& & & & & &Views: & & & &0 & & & &ViewRoots: & & & &0& & &AppContexts: & & & &0 & & & Activities: & & & &0& & & & & Assets: & & & &2 & &AssetManagers: & & & &2& &Local Binders: & & & &5 & &Proxy Binders: & & & 11Death Recipients: & & & &1&OpenSSL Sockets: & & & &0&SQL& & & & & & & &heap: & & & &0 & & & & MEMORY_USED: & & & &0&PAGECACHE_OVERFLOW: & & & &0 & & & & MALLOC_SIZE: & & & &0
阅读(4264)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'图片占用内存计算方法',
blogAbstract:'Android中有四种,分别是:ALPHA_8:每个像素占用1byte内存ARGB_4444:每个像素占用2byte内存ARGB_8888:每个像素占用4byte内存',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:4,
publishTime:3,
permalink:'blog/static/',
commentCount:2,
mainCommentCount:2,
recommendCount:1,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'0',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}}

我要回帖

更多关于 朋友阅读过的原创文章 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信