Android - Split Drawable

I am trying to break an image into pieces, say, for example, 16 pieces (4x4).

I found so many examples with java, but Android does not have a BufferedImage, and what not ... I think.

I have a worthy IDEA on how to do this, but I donโ€™t know where to start.

Should I use a bitmap or drawing?

Is there a way to split, or do I need to create my own method?

Should I use a GridView to store split images?

I donโ€™t want to communicate as a newbie, and I want someone to do it for me, I want it to be done, but I donโ€™t have to think much where to start, as I am new to Java and Android graphics.

I hope that most of my questions are answered and possibly even have examples that I cannot find for any reason.

+4
source share
2 answers

I think you need this

void createImageArrays() { Bitmap bMap = BitmapFactory.decodeResource(getResources(), image); Bitmap bMapScaled = Bitmap.createScaledBitmap(bMap, 240, 240, true); bitmapsArray[0] = Bitmap.createBitmap(bMapScaled, 0, 0, 80, 80); bitmapsArray[1] = Bitmap.createBitmap(bMapScaled, 80, 0, 80, 80); bitmapsArray[2] = Bitmap.createBitmap(bMapScaled, 160, 0, 80, 80); bitmapsArray[3] = Bitmap.createBitmap(bMapScaled, 0, 80, 80, 80); bitmapsArray[4] = Bitmap.createBitmap(bMapScaled, 80, 80, 80, 80); bitmapsArray[5] = Bitmap.createBitmap(bMapScaled, 160, 80, 80, 80); bitmapsArray[6] = Bitmap.createBitmap(bMapScaled, 0, 160, 80, 80); bitmapsArray[7] = Bitmap.createBitmap(bMapScaled, 80, 160, 80, 80); bitmapsArray[8] = Bitmap.createBitmap(bMapScaled, 160, 160, 80, 80); } 

The original image is 240x240, and I divided it into 9 parts 80x80

+14
source

BufferedImage in Java SE is similar to a bitmap in Android. Drawable is just an interface that tells you that something is available. This can be a bitmap, shape, color, etc.

+2
source

Source: https://habr.com/ru/post/1336411/


All Articles