READ THE RULES: Click here

Follow us on Facebook: https://www.facebook.com/xentax/ :)

Working with RGB24 and RGB alpha masks for transparency

Get your graphics formats figures out here! Got details for others? Post here!
Post Reply
finale00
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2382
Joined: Sat Apr 09, 2011 1:22 am
Has thanked: 170 times
Been thanked: 295 times

Working with RGB24 and RGB alpha masks for transparency

Post by finale00 » Wed Feb 20, 2013 12:37 am

I am looking at a pretty simple image format that someone sent me.
Here's the pic:

Image
(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?

Polefish
veteran
Posts: 94
Joined: Sat Jun 20, 2009 1:47 pm
Has thanked: 16 times
Been thanked: 13 times

Re: Working with RGB24 and RGB alpha masks for transparency

Post by Polefish » Wed Feb 20, 2013 1:11 pm

Sounds very interesting.
Could it be that the alpha mask(s) have/has a lower bit depth and just appears as three images with some colours?

finale00
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2382
Joined: Sat Apr 09, 2011 1:22 am
Has thanked: 170 times
Been thanked: 295 times

Re: Working with RGB24 and RGB alpha masks for transparency

Post by finale00 » Thu Feb 21, 2013 2:01 am

Ah, I parsed the pixels at 8bpp and it seems to have done the trick :)

Here's a sample:
You do not have the required permissions to view the files attached to this post.

Sir Kane
veteran
Posts: 98
Joined: Mon Aug 06, 2012 4:14 am
Been thanked: 77 times

Re: Working with RGB24 and RGB alpha masks for transparency

Post by Sir Kane » Fri Feb 22, 2013 12:34 am

Header size seems to be 32 bytes, with width and height at 0xC (two ushorts). Followed by width*height*RGB, followed by width*height*A.

Polefish
veteran
Posts: 94
Joined: Sat Jun 20, 2009 1:47 pm
Has thanked: 16 times
Been thanked: 13 times

Re: Working with RGB24 and RGB alpha masks for transparency

Post by Polefish » Fri Feb 22, 2013 12:24 pm

Sir Kane wrote:Header size seems to be 32 bytes, with width and height at 0xC (two ushorts). Followed by width*height*RGB, followed by width*height*A.
Could you explain the information after width and height? Do you mean bits per pixel with RGB?

Sir Kane
veteran
Posts: 98
Joined: Mon Aug 06, 2012 4:14 am
Been thanked: 77 times

Re: Working with RGB24 and RGB alpha masks for transparency

Post by Sir Kane » Fri Feb 22, 2013 1:41 pm

Wrote a simple tool to convert the images to TGA, but not sure if output is correct. Could you upload/send some more samples and possibly a screenshot of them in game so I can compare?
http://sktest.aruarose.com/sample.tga

finale00
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2382
Joined: Sat Apr 09, 2011 1:22 am
Has thanked: 170 times
Been thanked: 295 times

Re: Working with RGB24 and RGB alpha masks for transparency

Post by finale00 » Fri Feb 22, 2013 5:33 pm

Sir Kane wrote:Wrote a simple tool to convert the images to TGA, but not sure if output is correct. Could you upload/send some more samples and possibly a screenshot of them in game so I can compare?
http://sktest.aruarose.com/sample.tga
Unfortunately I don't know where it is in the game LOL
Here are some more samples with an actual character, so I think if you get something you'll know if it's right

viewtopic.php?p=83197#p83197

Note the different image formats as well as skewing.
This pack contains skewed images

viewtopic.php?p=83207#p83207

Post Reply