Is it possible to create a Bitmap array in android

I want to create a bitmap array. Is it possible? If so, is this a way to declare a Bitmap array. and how to initialize it?

thanks

+7
source share
5 answers

You can use Arraylist:

ArrayList<Bitmap> bitmapArray = new ArrayList<Bitmap>(); bitmapArray.add(myBitMap); // Add a bitmap bitmapArray.get(0); // Get first bitmap 

or just an array of a bitmap, for example:

 Bitmap[] bitmapArray = new Bitmap[]; 

However, be careful about the size of your image. You will probably have problems if you try to save a lot of large images.

+27
source

Yes, it is possible, If bitmap1 and bitmap2 are bitmap objects. I can assign them to an array as follows.

 Bitmap bitmap1 = BitmapFactory.decodeResource(getResources(),R.drawable.a_thumb);//assign your bitmap; Bitmap bitmap2 = BitmapFactory.decodeResource(getResources(),R.drawable.anotherimage);//assign your bitmap; Bitmap[] arrayOfBitmap = {bitmap1, bitmap2}; 

Thanks Deepak

+2
source

Like any array, for example:

 Bitmap[] bitmaps = new Bitmap[] { BitmapFactory.decodeResource(...) /* etc. */ } 

There is nothing special about the objects in the Bitmap s array.

+1
source

You can make bitmap aaray in android like this,

 byte[] bMapArray= new byte[buf.available()]; buf.read(bMapArray); Bitmap bMap = BitmapFactory.decodeByteArray(bMapArray, 0, bMapArray.length); image.setImageBitmap(bMap); 

You can read more about this in this developer article.

Use this too

0
source

All of the above solutions are possible, but the usual case actually uses HashMap, as is the case with image downloaders and asynchronous raster downloaders.

Bitmap is an object that can be different (String arrays, Integer arrays, etc.), so you can change the methods that you will also find for storing arrays of bitmap images.

0
source

All Articles