Android中擦除Bitmap中的某一块

以前要截取Bitmap中的图片使用的一块块的拼接,虽然可以实现,但是效率很低。想了很久,无意中看到网上的对BITMAP图片的RGB信息进行修改,然后想出了这个办法,感觉用起来还是挺舒服。很多出错处理都没有写,只实现基本功能啊

public static Bitmap setTransparentAreaForBitmap(Bitmap b, 
        int width, int height, int paddingleft, int paddingtop) {
    if (b == null) {
        return null;
    }
    int []pix = new int[width * height];
    for (int j = 0; j < height; j++) {
        for (int i = 0; i < width; i++) {
            int index = j * width + i;
            pix[index] = 0x00000000;
        }
    }
    b.setPixels(pix, 0, width, paddingleft, paddingtop, width, height);
    return b;
}

你可能感兴趣的:(android,null)