tags:

views:

20

answers:

0

Hi,

I had two images. Initial state - image1 is shown. What I need: at some point change part of image1 with equal part of image2. Or, in other words - cut part of image2 and place it on image1. Part need to be changed is triangle or quadrangle

I tried to use Path to make a form, clipPath on canvas and then draw image2. This follows (depending on Region.Op setting) to black screen or to part which need to be changed - is changed, but part outside the path is black.

I tried to replace pixels in Bitmap - but this is extrimly slow.

As I know - first case (with SunJDK analogues) works in SunJDK. I suppose that same should work for Android too and probably I do something wrong.

Code I used:

Bitmap _bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.a0);
canvas.drawBitmap(_bitmap, 0, 0, _paint);
//canvas.clipPath(p);
canvas.clipPath(p, Region.Op.REPLACE);
Bitmap b = BitmapFactory.decodeResource(getResources(), R.drawable.a2);
canvas.drawBitmap(b, 0, 0, _paint);

I do something wrong? Can you please advise what need to be changed or how to do what I need in other way?

Thanks a lot!

Evgeny.