0
我想從32位PNG圖像創建一個帶有ALPHA_8配置的位圖。要做到這一點,我請撥打decodeResource(Resources res, int id, Options opts)
,其中opts.inPreferredConfig = Bitmap.Config.ALPHA_8
。但是,它會返回帶有ARGB_8888配置的位圖:爲什麼BitmapFactory.decodeResource與inPreferredConfig = Bitmap.Config.ALPHA_8會返回帶有Bitmap.Config.ARGB_8888的位圖?
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ALPHA_8;
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), id, options);
// Output: "bitmap.getConfig() returns ARGB_8888"
Log.w(tag, "bitmap.getConfig() returns " + bitmap.getConfig());
爲什麼會發生?如何使其正常工作?