我正在尝试将图像拆分成多个部分,例如 16 个 block (4x4)。
我发现了很多关于 java 的例子,但是 Android 没有 BufferedImage 什么的……我想。
我对如何做有一个不错的想法,但我真的不知道从哪里开始。
我应该使用位图还是可绘制对象?
是否有拆分方法,还是我必须制作自定义方法?
我应该使用 GridView 来保存拆分图像吗?
我不想给人留下新手的印象,也不想让别人为我做这件事,我想要自己做这件事的满足感,但我不知道从哪里开始,因为我是新手到 Java 和 Android 中的图形。
希望我的大部分问题都能得到解答,甚至可能有可用的示例,但由于某种原因我找不到。
最佳答案
我想你需要这个
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);
}
原图是240x240,我把它分成了9张80x80
关于Android - 拆分可绘制对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4754985/