In this tutorial I will explain how to read Drawable from resources as Bitmap and than I will write down some common techniques for processing Bitmaps.
public final static Integer[] imageResIds = new Integer[]{
R.drawable.a, R.drawable.b, R.drawable.c,
R.drawable.d, R.drawable.e, R.drawable.f,
R.drawable.k, R.drawable.l, R.drawable.m};
loadBitmap(imageResIds[index], mImageView);
public void loadBitmap(int resId, ImageView imageView) {
//Now we have bitmap object from drawable resource. we can scale this bitmap
//according to device screen density.
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), data);
}
Note: This method can cause out of memory error.
- If you want to avoid this exception use scaled down version of bitmap in memory.
- Process Bitmaps Off the UI thread (Use Async Task).
Author:
Hammad Tariq
Android Developer
Note: This method can cause out of memory error.
- If you want to avoid this exception use scaled down version of bitmap in memory.
- Process Bitmaps Off the UI thread (Use Async Task).
Author:
Hammad Tariq
Android Developer
No comments:
Post a Comment