Working with RGB24 and RGB alpha masks for transparency
Posted: Wed Feb 20, 2013 12:37 am
I am looking at a pretty simple image format that someone sent me.
Here's the pic:

(looks like a dragon quest character lol)
As you can see, there is a lot of garbage around the actual character.
Under the image, there is a set of 3 black/white images used as the alpha mask. The left one has a couple red-pixels along the side for some reason, the middle has yellow pixels, and the right has blue pixels. It is like 2 or 3 pixels along the very edge so you wouldn't see it from here.
The size of each mask image is 1/3 the size of the actual image.
If I just manually cut up the image, grab one of those masks, stretch it to the size of the image I want and then delete the stuff that should be transparent, I get the correct image.
I would like to write a tool that will automate this process for me, but am not sure how to deal with the masks.
My algorithm looks something like
1: parse header
2: get pixel data
3: for each mask
4: stretch the mask to the size of the image
5: Do some bit-wise AND's on the appropriate color (I'm guessing this is how alpha masks work)
But is "stretching the mask" really the way to do it?
How would a game engine handle this?
Here's the pic:

(looks like a dragon quest character lol)
As you can see, there is a lot of garbage around the actual character.
Under the image, there is a set of 3 black/white images used as the alpha mask. The left one has a couple red-pixels along the side for some reason, the middle has yellow pixels, and the right has blue pixels. It is like 2 or 3 pixels along the very edge so you wouldn't see it from here.
The size of each mask image is 1/3 the size of the actual image.
If I just manually cut up the image, grab one of those masks, stretch it to the size of the image I want and then delete the stuff that should be transparent, I get the correct image.
I would like to write a tool that will automate this process for me, but am not sure how to deal with the masks.
My algorithm looks something like
1: parse header
2: get pixel data
3: for each mask
4: stretch the mask to the size of the image
5: Do some bit-wise AND's on the appropriate color (I'm guessing this is how alpha masks work)
But is "stretching the mask" really the way to do it?
How would a game engine handle this?