您想将位图分成几部分。我假设您想从位图中剪切相等的部分。比如说你需要一个位图的四个相等的部分。
这是一种将位图分成四等份并将其放在位图数组中的方法。
public Bitmap[] splitBitmap(Bitmap src) {
Bitmap[] divided = new Bitmap[4];
imgs[0] = Bitmap.createBitmap(
src,
0, 0,
src.getWidth() / 2, src.getHeight() / 2
);
imgs[1] = Bitmap.createBitmap(
src,
src.getWidth() / 2, 0,
src.getWidth() / 2, src.getHeight() / 2
);
imgs[2] = Bitmap.createBitmap(
src,
0, src.getHeight() / 2,
src.getWidth() / 2, src.getHeight() / 2
);
imgs[3] = Bitmap.createBitmap(
src,
src.getWidth() / 2, src.getHeight() / 2,
src.getWidth() / 2, src.getHeight() / 2
);
return divided;
}