Android Question Shuffling channels in bitmap?

Troberg

Well-Known Member
Licensed User
Longtime User
Is there as simple way to take channels from one bitmap and use them to replace channels in another bitmap.

For example, taking the alpha (A) channel from one bitmap and "transplant" it to the A channel of another bitmap, without touching the RGB channels?

Or, taking the R channel from one bitmap and use it as A in another, also without touching other channels?

Or, for that matter, switching R and B channels in a bitmap, leaving the rest untouched.

In other words, treating a bitmap like four separate "sheets", which may be re-stacked or replaced individually.
 

sorex

Expert
Licensed User
Longtime User
you can always read the pixels of the image grab the a,r,g or b value and (re)place it in the other one.

it might take a while unless there are some libs that use a more advanced method.
 
Upvote 0

Troberg

Well-Known Member
Licensed User
Longtime User
Yeah, I've thought about that, but I'm going to do it a bit too much to do it pixel by pixel.

My main need is the first example: replace the alpha map. The rest are just "for extra credits", stuff I think I may someday need, but not at the moment.

Edit: For my needs, it would also work if I was able to add an alpha channel (from another bitmap) to an RGB bitmap, creating a ARGB bitmap.

Edit 2: It would also work to do the opposite. I could have a blank (A data only, RGB all black) ARGB, then copy RGB data from another bitmap, replacing the RGB data in the ARGB.

Just to clarify my needs:

I want to be able to colorscheme icons. I intend to do that by having a bitmap with the icon shape in the A channel, then make a nice colorschemed gradient on another bitmap. Then, somehow, I want to use the A channel bitmap as a cookie cutter to cut out the correct shape from the color bitmap.
 
Last edited:
Upvote 0

sorex

Expert
Licensed User
Longtime User
I think what you need is a grayscale icon and you overlay the gradient.

I'm not sure if that will work with an icon in the alpha channel only as that only tells how much opaque the image is.
 
Upvote 0

Troberg

Well-Known Member
Licensed User
Longtime User
I'm not sure if that will work with an icon in the alpha channel only as that only tells how much opaque the image is.

Well, the icon is a simple shape, no colors, no shades, just a shape defined by the A-channel. The colors are supposed to be supplied by the gradient, and the A-channel "cuts out" the correct shape, leaving the outside transparent.

Edit: Have a look at JukeDroid or SerialVideoPlayer screenshots in Google Play (links in my sig) to see what the final effect should be like.
 
Last edited:
Upvote 0

sorex

Expert
Licensed User
Longtime User
right, that would work.

for images like icons it will be fast enough aswell.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
adding the gradient on top of the alpha, you just need to give it a fixed color value.
 
Upvote 0
Top