I have some bitmap A which I modify to produce bitmap B. I want to efficiently produce a bitmap D by XORing the pixels values of A and B together such that D XOR A produces bitmap B and D XOR B produces bitmap A. The reason I need this is to store the differences between the bitmaps so I can reverse changes that I've made later.
So far I've tried:
1. Drawing A onto B with a paint object that I've called .setXfermode(new PorterDuffXfermode(PorterDuff.Mode.XOR)) on. This works when the alpha of A and B is 255 everywhere but anything below produces undesirable results. If I XOR A onto A, for example, I'd expect the result to be a blank image. With this xfer mode, most of A will disappear but the parts without full alpha will remain.
2. Drawing A onto B with a paint object that I've called .setXfermode(new PixelXorXfermode(0)) on. This xfer mode destroys alpha values, which isn't what I want. I'm also not sure what useful things I can set the constructor value to.
What can I do? I need something that will treat the pixel values as plain values and not treat the alpha values as a special case. I need this to be fairly fast (like the above paint types are) and using something like setpixel/getpixel or doing the calculations myself in a byte will be far too slow.