user868395
user868395

Reputation: 47

Android: How to cut bitmap[25] from bitmap[25]

i have two Bitmap[] (for example "BitM1" and BitM2) Need to cut BitM1[0] from BitM2[0], BitM1[1] from BitM2[1] (using Xfermode mode.xor)... etc

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]);

not work... Crashed...

Upvotes: 1

Views: 243

Answers (1)

Wizetux
Wizetux

Reputation: 756

You are never changing the value of K in the code above, so you are always placing the new Bitmap at location vk[0]. Thus when you attempt to get vk[5], it is not defined. BOOM...Crash!

Upvotes: 2

Related Questions