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.

Graphics > Transparency with Gfx2Gba

#12035 - dagamer34 - Mon Oct 27, 2003 9:10 pm

How do you make a color transparent in Gfx2Gba. I don't want to use the *default* black color because it is needed in my images. It says something about an option (-a) and a color from 0-255. I don't get it!! I want to use the color purple (255, 0, 255) as my transparent color but i don't know what to put.

Also, Gfx2Gba seems to screw up colors on one of my images. I have lots of hues of blue and it ends up as red and even white? Should i spend time fixing this or is it a bug in the utility? The image is saved in 256-color format.
_________________
Little kids and Playstation 2's don't mix. :(

#12037 - sajiimori - Mon Oct 27, 2003 9:54 pm

I don't know about the second problem, but the default transparent color is not 'black', it's palette index 0. You can set index 0 to magenta (255, 0, 255) and use that as your transparent color, and set a different index to black. Alternatively, you could leave index 0 as black, and put magenta in a different index and use -a to specify which one.

#12075 - dagamer34 - Wed Oct 29, 2003 12:19 am

How would i go about changing the index of the palette for transparency?
_________________
Little kids and Playstation 2's don't mix. :(

#12088 - poslundc - Wed Oct 29, 2003 5:13 am

The zeroth element of the palette is always the transparent element.

This means if you are using a 256-colour palette, colour 0 is always transparent.

If you are using 16-colour palettes, then colour 0 of your 16-colour palette is always transparent. (So if you use all 16 palettes, you will have a transparent colour at the beginning of each 16-colour palette.)

This applies to both sprite and background palettes.

(Note: if you have a sprite/background that uses a 16-colour palette and another sprite that uses a 256-colour palette, the zeroth element of the 16-colour palette will be transparent for the the 16-colour element, and solid for the 256-colour element if it isn't the first palette.)

The colour you set to colour 0 of the background palette is the colour that is used as the "backdrop", ie. the colour drawn when there are no sprites/backgrounds occupying a pixel.

These are all fundamental to the way the GBA's 2D hardware operates, and to my knowledge cannot be changed.

Dan.

#12093 - sajiimori - Wed Oct 29, 2003 7:51 am

That's true, but it looks like Gfx2Gba will do the next best thing and rearrange your palette for you when you use -a to specify a different index to be transparent. But I haven't used it myself... Either way, it seems like you should just make your palette the right way to begin with, i.e. use index 0 as the transparent color.

#12181 - dagamer34 - Sun Nov 02, 2003 9:08 pm

So, let me ask again, how to i make a color transparent. I'll give you an example.

I have 3 colors in my 16-color palette and they are (in this exact order)
0x0000 (black),
0x6318 (magneta, purple, whatever you want to call it, its RGB value is 255, 0, 255),
and 0x7fff (gray),
the rest are 0x0000 (which i am not worried about)

Now, i have black in my picture but i don't want it to be in my first index (i need that color). I want to have purple as the transparent color. Without changing the raw data itself to make the corrections in swapping the first 2 palette indices, is there anything i can do?

And why is black defaulted as being in the first index?? The first color in my picture is purple!
_________________
Little kids and Playstation 2's don't mix. :(

#12184 - sajiimori - Mon Nov 03, 2003 7:59 am

Quote:

So, let me ask again, how to i make a color transparent.

Try using paint thinner.
Quote:

Now, i have black in my picture but i don't want it to be in my first index (i need that color).

Then rearrange your palette.
Quote:

Without changing the raw data itself to make the corrections in swapping the first 2 palette indices, is there anything i can do?

If that -a parameter from Gfx2Gba will rearrange the palette for you, use that. Otherwise, fix the image yourself, either by hand or by writing a program to do it for you.
Quote:

And why is black defaulted as being in the first index??

There is no universal "default" for black being the first color in a palette. If your software always makes black the first color, feel free to complain to the manufacturer.
Quote:

The first color in my picture is purple!

There's no rule that says the order of the palette must correspond to the order that colors appear in the image.

#12205 - dagamer34 - Mon Nov 03, 2003 9:14 pm

Well, i guess i might as well do it the hard way. Someone should make an easy to use tool...
_________________
Little kids and Playstation 2's don't mix. :(

#12211 - dagamer34 - Tue Nov 04, 2003 12:39 am

I fixed the problem with the red in my bitmaps. Seems when i was initializing the HAM text system, i messed with values of the palette being used by my bg.

One thing though that i can't get. I have 3 bitmaps that i want to display at the same time. I want them to use the same palette though. How would i do it? If possible, please give an example.
_________________
Little kids and Playstation 2's don't mix. :(

#12214 - sajiimori - Tue Nov 04, 2003 2:00 am

How are you displaying bitmaps now? Have you made an attempt at displaying 3 at once?