Android - Split Drawable

后端 未结 2 1394
一个人的身影
一个人的身影 2020-12-28 11:13

I am attempting to split an image into pieces, lets say for example 16 chunks (4x4).

I have found so many examples with java, but Android does not have BufferedImage

相关标签:
2条回答
  • 2020-12-28 11:46

    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 pieces of 80x80

    0 讨论(0)
  • 2020-12-28 11:48

    BufferedImage in Java SE is like a Bitmap in Android. Drawable is just an interface that tells you that something is drawable. It can be a bitmap, shape, color, etc.

    0 讨论(0)
提交回复
热议问题