Image splitting in Android
Image split can be required by different android puzzle application where there is a need to divide the one complete picture into different pieces.
Here is the function that takes three argument one is the imageview that holds your complete image and the other two are the number of rows and columns.
- /* globally declare this arraylist, this will be used to display your image chunks into the gridview*/
- ArrayList<Bitmap> imageChunksStorageList ;
- private void splitImage(ImageView image, int rows, int columns)
- {
- //For height and width of the small image chunks
- int chunkHeight,chunkWidth;
- Bitmap image; // use to store image chunks
- int chunkNumbers=rows*column;
- //To store all the small image chunks in bitmap format in this list
- bitmapStorageList = new ArrayList<Bitmap>(chunkNumbers);
- //Getting the BitmapDrawable from the imageview where your image is displayed
- BitmapDrawable drawable = (BitmapDrawable) image.getDrawable();
- Bitmap bitmap = drawable.getBitmap();
- Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth(), bitmap.getHeight(), true);
- //setting the height and width of each pieces according to the rows and columns
To read this full blog on Image splitting in Android please visit FindNerd.
Apart from this if you have any query regarding Android Programming you can ask your query at our Android Developer Forum & your query will be resolved by the experts here, in a very short span of time.
Post Your Ad Here
Comments