如何切分画面分成相等的部分? [英] How to cut the picture into equal parts?
本文介绍了如何切分画面分成相等的部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的Android应用程序的图像。如何切断这个图片到9或12等份,并添加这部分数组?
I have images on my android app. How cut this picture into 9 or 12 equal parts and add this parts an array?
推荐答案
这将工作:
ArrayList<Bitmap> bs= new ArrayList<Bitmap>();
Bitmap b= BitmapFactory.decodeResource(getResources(),R.drawable.photo1);
divideImages(b);
private void divideImages(Bitmap b) {
// TODO Auto-generated method stub
final int width = b.getWidth();
final int height =b.getHeight();
final int pixelByCol = width / 2;
final int pixelByRow = height / 2;
//List<Bitmap> bs = new ArrayList<Bitmap>();
for(int i=0;i<2;i++){
System.out.println("row no. "+i);
for(int j=0;j<2;j++){
System.out.println("Column no."+j);
int startx=pixelByCol*j;
int starty=pixelByRow*i;
Bitmap b1=Bitmap.createBitmap(b,startx,starty,pixelByCol,pixelByRow );
bs.add(b1);
b1=null;
}
}
b=null;
}
这篇关于如何切分画面分成相等的部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文