gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Question with Ham and alpha

#39356 - Dib - Thu Apr 07, 2005 11:18 pm

I've hit a snag with designating an alpha value.

From the tutorials:
Quote:
There is one thing you'll need to know before we start that I didn't explain fully earlier - transparency (or alpha blending). The first color in the palette array is the alpha color. What this means is that any part of your image which has that color is transparent. The system palette in Windows has black in the first spot. Therefore, any part of my image which is black will not be drawn to the screen. You can tell this if you look at outline_plain.bmp and compare it to how it looks in the 'game.'


By the way I'm reading this, it should mean that if I alter the first value in my .pal.c file (0x0000 to 0x7C1F) it should alter the alpha blending so instead of black being transparent it would be the color of my choice. So if I were to recompile, all the black areas that were transparent before should then be solid black, and all the pink portions would be invisible. This isn't happening for me.

Am I missing out on something, or if not this then how do I change the transparency value? The sprites I've arranged require #000000 black values to show up, and I already planned on using #FF00FF for my alpha color.

#39357 - poslundc - Thu Apr 07, 2005 11:36 pm

Dib wrote:
By the way I'm reading this, it should mean that if I alter the first value in my .pal.c file (0x0000 to 0x7C1F) it should alter the alpha blending so instead of black being transparent it would be the color of my choice.


You've got it backwards. The zeroth palette index is always transparent, no matter what colour you put there.

This means that any pixels in your image that reference colour 0 will be transparent, no matter what colour is in that zeroth slot.

Changing the colour that's in slot 0 doesn't change which pixels in your image reference slot 0. If I have a bunch of green pixels in my image and change the green entry of my palette to yellow, it'll make all of the green pixels yellow, but they're still pointing to the same palette index.

Dan.

#39362 - Dib - Fri Apr 08, 2005 12:03 am

Okay, I finally got the idea. I thought there was something about the "system palette in Windows has black in the first spot" that I wasn't understanding. Now I discovered that I can open the image palette in Paintshop and rearrange the colors so that #FF00FF, instead of having an index of 253, was index 0. I put it all back together and it worked.

Now is there an easier way to do this than having to edit every sprite image to rearrange the palette? I tried using the -a switch in gfx2gba, but to no avail (when I had attempted -a253, it switched the black and pink colors but nothing was transparent).