Skip to content

Instantly share code, notes, and snippets.

@Amokrane
Created January 30, 2012 22:51
Show Gist options
  • Save Amokrane/1707321 to your computer and use it in GitHub Desktop.
Save Amokrane/1707321 to your computer and use it in GitHub Desktop.
Clever way to decode a bitmap
// Allocate a bitmap of the desired size
Bitmap b = Bitmap.createBitmap(256, 256, BitmaP.Config.ARGB_8888);
// Set the allocated bitmap as the target
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inBitmap = b;
// Decode resource in pre-allocated bitmap
BitmapFactory.decodeResource(resources, R.drawable.texture, opts);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment