2017-11-25 3 views
0

32ビットPNGイメージからALPHA_8構成のビットマップを作成します。それを行うには、私はdecodeResource(Resources res, int id, Options opts)と呼ばれます。opts.inPreferredConfig = Bitmap.Config.ALPHA_8です。ただし、ARGB_8888設定のビットマップを返します。inPreferredConfig = Bitmap.Config.ALPHA_8でBitmapFactory.decodeResourceを実行すると、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()); 

なぜそれが起こりますか?正しく動作させるには?

答えて

0

あなたがソースビットマップをALPHA_8でデコードできないため、Androidは自動的にARGB888をデコードしてデコードします。

関連する問題