前言
Android是一個內存相當吃緊的系統,那么在做程序的過程中使用內存就需要相當謹慎,而我們接觸最大的大對象估計就是Bitmap了,那么下面就根據Bitmap.Config值的介紹來看下Bitmap在內存中存儲的形式,那么在根據實際場景選擇合適的配置進行Bitmap存儲
原文地址:http://www.cnblogs.com/luoaz/p/4374886.html
Bitmap.Config
Possible bitmap configurations. A bitmap configuration describes how pixels are stored. This affects the quality (color depth) as well as the ability to display transparent/translucent colors.
首先這是一個枚舉型,它代表了Bitmap可以的配置情況。一個配置描述的是這些像素信息是如何存儲的。這個影響到了圖片質量和透明度。
ALPHA_8:Each pixel is stored as a single translucency (alpha) channel.
每個像素信息只存儲了alpha這一項信息。
ARGB_4444:This field was deprecated in API level 13. Because of the poor quality of this configuration, it is advised to use ARGB_8888
instead.
這個值在level 13的時候就已經不被建議使用了,因為他是一個低質量的配置,它被建議使用ARGB_8888
ARGB_8888:Each pixel is stored on 4 bytes. This configuration is very flexible and offers the best quality. It should be used whenever possible.
每個像素信息占用4個字節(即32個二進制位)的存儲空間,alpha、red、green、blue各占8個二進制位。這個配置項是非常靈活,並提供了最好的質量。他應該在可能的情況下盡量被使用。
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 may be useful when using opaque bitmaps that do not require high color fidelity
每個像素信息占用2個字節(即16位二進制位)並且至存儲了RGB的信息沒有alpha信息,其中Red5位,Green6位,Blue5位。這個配置項在不需要提供透明度的情況下更有用。
后記
以上就是配置項的詳細介紹,有了這些知識那么我們在接下來出來圖片的時候就會更加得心應手了