Android 系統(tǒng)會根據(jù)圖片格式和APP 指定的編碼綜合判斷, 得出最終使用的編碼. 可以參考源代碼 (Android 8): SkAndroidCodec::computeOutputColorType(SkColorType requestedColorType):
{
124 switch (requestedColorType) {
125 case kARGB_4444_SkColorType:
126 return kN32_SkColorType;
127 case kN32_SkColorType:
128 // F16 is the Android default for high precision images.
129 return highPrecision ? kRGBA_F16_SkColorType : kN32_SkColorType;
130 case kIndex_8_SkColorType:
131 if (kIndex_8_SkColorType == suggestedColorType) {
132 return kIndex_8_SkColorType;
133 }
134 break;
135 case kAlpha_8_SkColorType:
136 // Fall through to kGray_8. Before kGray_8_SkColorType existed,
137 // we allowed clients to request kAlpha_8 when they wanted a
138 // grayscale decode.
144 case kRGB_565_SkColorType:
145 if (kOpaque_SkAlphaType == this->getInfo().alphaType()) {
146 return kRGB_565_SkColorType;
147 }
148 break;
153 }
161 // |suggestedColorType| may be kN32_SkColorType or kIndex_8_SkColorType.
162 return highPrecision ? kRGBA_F16_SkColorType : suggestedColorType;
}
可以看出, 4444被直接轉(zhuǎn)為8888(API 官方文檔里有描述). 如果圖片中沒有透明度信息, 565才不會被轉(zhuǎn)為8888
Android bitmap config你理解對了嗎实辑?在寫本文之前捺氢,我還以為自己對android的bitmap很熟悉,直到自己親手寫代碼實(shí)踐剪撬,才發(fā)現(xiàn)自己錯了很多年摄乒。真是汗顏啊! Bitmap Config 首先馍佑,根據(jù)Androi...