0

Possible Duplicate:
Android - Read PNG image without alpha and decode as ARGB_8888

In this tutorial I'm going through, a .png image is being loaded into a Bitmap object using BitmapFactory.Options.inPreferredConfig to set the Bitmap.Config to ARGB_8888 beforehand, but it doesn't appear to be working (tested the author's code - the image loads as an RGB_565 bitmap).

BitmapFactory.Options options = new BitmapFactory.Options();

options.inPreferredConfig = Bitmap.Config.ARGB_8888;
bitmapOrig = BitmapFactory.decodeResource(this.getResources(), R.drawable.sampleimage, options);

What would be the correct way to do it?

Community
  • 1
  • 1
white_pawn
  • 205
  • 1
  • 4
  • 10
  • is bitmapOrg == null after you decode it? – irwinb Sep 29 '11 at 21:58
  • I don't see anything wrong in your code. It should work without any issues. Are your alpha layers being shown? Then it works. – Michell Bak Sep 29 '11 at 22:36
  • Looks correct. But ARGB_8888 is the default anyway, no need to set it explicitly. Can you post a few more details (android version, how you test that the bitmap got a format, ..). –  Sep 29 '11 at 22:41
  • @irwinb No. It's definitely there, only as RGB_565. – white_pawn Sep 30 '11 at 00:24
  • @alextsc My emulator's running v2.3. Right after I decode the resource, I call bitmapOrig.getConfig() to get the bitmap format (RGB_565). – white_pawn Sep 30 '11 at 00:28
  • UPDATE: I've just created a new AVD (v2.2) and now the code's working fine! Now, why is it that it won't work with Gingerbread? – white_pawn Sep 30 '11 at 00:38

0 Answers0