It's possible to access the alpha channel of a given bitmap with extractAlpha()
, but I haven't been able to find any way to actually set the alpha channel of a bitmap.
How can multiple greyscale images be recombined as channels into a Bitmap with Android?
It is quite possible to re-combine separate channels back into an ARGB image. You just need the grayscale channel images and an image with the alpha channel you want - note that this is not an opaque grayscale image, but an image with the alpha you want. You then draw each channel with a
Paint
using the appropriatePorterDuffXfermode
onto a blank, black-filled Bitmap.With the above code and the following 4 images (red, green, blue, and alpha, respectively):
We get the following result:
Just a quick note: the red oval is an opaque, red oval on a transparent background - the color doesn't matter for this one, but the alpha does
Manipulating Bitmaps is a farily simple thing, when to access the pixel (bytes) directly. To do that in Android you can do it over this approch
Now you can do any image manipulation, tranformation or combination you like.
I hope this is what you were looking for.
Have you tried with canvas? The following looks like a hack, but maybe it will work. I have not tested it myself.