【问题标题】:How to cut the picture into equal parts?如何将图片切成等份?
【发布时间】:2011-09-29 10:33:39
【问题描述】:

我的 Android 应用上有图片。如何将这张图片分成 9 或 12 等份,然后将这些部分添加到一个数组中?

【问题讨论】:

标签: java android image android-bitmap


【解决方案1】:

这将起作用:

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;

【讨论】:

    猜你喜欢
    • 2011-06-20
    • 1970-01-01
    • 1970-01-01
    • 2022-06-16
    • 2020-11-08
    • 2020-01-12
    • 1970-01-01
    • 1970-01-01
    • 2012-08-30
    相关资源
    最近更新 更多