我有两个Bitmap [](例如“BitM1”和BitM2) 需要从BitM2 [0]中删除BitM1 [0],从BitM2 [1]中删除BitM1 [1](使用Xfermode mode.xor)......等等
Bitmap[] vk = new Bitmap[25];
int k=0;
for (v=0;v<25;v++)
{
Bitmap bitmap2 = BitM1[v];
Bitmap bitmap1 = BitM2[v];
vk[k]=Bitmap.createBitmap(bitmap2.getWidth(), bitmap2.getHeight(), bitmap2.getConfig());
Canvas canvas = new Canvas(vk[k]);
Paint paint = new Paint();
paint.setFilterBitmap(false);
canvas.drawBitmap(bitmap2, 0, 0, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.XOR));
canvas.drawBitmap(bitmap1, 0, 0, paint);
bitmap2.recycle();
bitmap1.recycle();
}
imgv3.setImageBitmap(vk[5]);
不行......崩溃......
答案 0 :(得分:2)
您永远不会在上面的代码中更改K的值,因此您始终将新的位图放在位置vk [0]。因此,当您尝试获取vk [5]时,它未定义。咚......崩溃!