Hi,

I have a Bitmap object called A and a Bitmap object called B. I want
to produce a Bitmap object C that is produced by XORing the pixels
values from A against the pixel values from B. Specifically, the
integer pixel values should be combined using bitwise XOR.

The reason I want this is when transforming some bitmap from image A
to B, I want to produce an image of the differences C so that I can
convert B back to A by XORing C onto B.

I've tried drawing bitmap A onto B using a Paint object
with .setXferMode(PorterDuffXfermode(PorterDuff.Mode.XOR))) but this
does not perform a bitwise XOR on the pixel values as the alpha values
are treated as special cases as it says in the documentation (i.e.
XORing C onto B does not generate A when non-opaque pixels are used):

http://developer.android.com/reference/android/graphics/PorterDuff.Mode.html
"PorterDuff.Mode        XOR     [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1
- Sa) * Dc]  "

I tried variations of .setXfermode(new PixelXorXfermode(0)) but the
documentation says PixelXorXfermode does not consider the alpha values
at all.

Is there any efficient ways to do what I want here with API calls? If
there really isn't a XOR paint mode I can use, perhaps there are some
weird tricks I could use to do this.

The only method I can see is to use .copyPixelsToBuffer to copy A and
B into int arrays, XOR the arrays with a for loop, then copy the
pixels into C. This uses a lot of memory and could be done faster if
it was performed in-place by some native function. Or perhaps there
are smarter ways to do this?

Thanks.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to