more about transparent colors
Endymion

In fact I have another problem.... I changed my message on the last topic, but of course nobody read it, because the topic was supposed to be over...

I loaded an 8 bits bitmap, that has only 2 colors: white and full yellow, with the PALETTE palette... I want the white to be transparent...

so I used:

palette[0].r = 63;
palette[0].g = 63;
palette[0].b = 63;

so the transparent color be white... but it does not work... the yellow is transparent, instead.

Then I tried not to set values to the index 0 like above... then I printed the values of the zero index... I presumed there should be the yellow color, because the yellow is transparent... but instead the zero index is 0 0 0..... and the yellow is still transparent.

Sorry about the double message...

spellcaster

The colors are not important. The color with index 0 will always be transparent. If white is index #0 it will be transparent. If yellow is the first color, that will be transparent.

Endymion

ok... but then when I do this:

palette[0].r = 63;
palette[0].g = 63;
palette[0].b = 63;

I am making the zero index color white, correct?

And my image has white parts...

Shouldn´t the white parts be transparent at this point? But they are not...

What am I doing wrong?

Steve Terry

are you setting the palette... you must set it after asigning the values, otherwise they are set.. but not in the CRT registers, which is where the palette data is stored.

something like set_palette(palette);

Endymion

Yes... but this is another question I have... If I do this, the "screen" bitmap goes white.. I assume that´s because I set the zero index of the palette to white....

Shouldn´t I set the palette for a specific bitmap....

These stuff are not making much of a sense to me...

LoHoL

try in your paint program change the palette( replace white with yellow)
another solution is to use truecolor mode instead of 8 bit and replace your transparent color with magic pink.

Quote:

I changed my message on the last topic, but of course nobody read it, because the topic was supposed to be over...

oh and a post wich is 10 hours old isn't dead;)

23yrold3yrold

Setting your 0 color to white does not mean that all white bits become transparent. It means that all parts that use color index 0 become transparent, like they were when color 0 was black or whatever. You can have a pallete that's all white; only the ones referencing the color in index 0 are going to be transparent.

Make color 0 black. Then color the parts you want transparent with THAT black. Not any old black, the one in that color index. Bitmaps in 8-bit don't even store colors; they store indices into the pallete, so the color doesn't even matter. All that matters is that any pixel in a bitmap referencing element 0 in the pallete (whatever it is) will be transparent.

I can see how this can be confusing for a newbie, so hopefully I've spelt it out sufficiently. Ask for more info if your still confused.

The other option is to switch to a higher color depth per LohoL's suggestion. In 16 and higher color depths, bright purple (max red and blue, no green) is always drawn transparent, because truecolor modes store actual colors instead of pallete indecies (like 8-bit mode). In truecolor modes, you don't even use palletes.

spellcaster

Try to blit the sprite as a normal bitmap. If you set index 0 to white, and the sprite has only 2 colors, you should see a completely white rectangle.

It works like this: Each pixel is just the index to the palette. So, even if all your palette entries are white, the actual sprite can have up to 256 different colors (which would be all white).

But only these parts which refer to the white at palette index #0 will actually be transparent.

Endymion

Thank you all... I get the concept now... So I must make the pixels I want transparent to point to the zero index of the palette... doesn´t matter the color stored in the zero index.

I guess the white in my bitmap is pointing to a diferent index... that´s why it is not transparent...

But how do I choose the index that a pixel is pointing to? In the paint program or in the code? In the paint I can only think about changing the color, but not determining the position of the color... In the code sounds more reasonable to me... but how can I go through the matrix of the bitmap... I understand it defines a pointer and then a Matrix... but I have seen someone use an easy way to detecting the end of collums and lines in the matrix... how? Can you post an example code of how searching through the matrix and replacing the indexes that the pixels are pointing to?
Either way I will be trying to solve it while you don´t answer me...

About the suggestion of switching to a higher depth mode... I do not want to, because I could not initiate graphics in 16bits mode in some video cards... mine works ok... But it worked erratically in a Voodoo3...

Sorry about the long message... I am really a newbie to this....

spellcaster

You would do it in your gfx program, normally.
What gfx program are you using?

Endymion

hehe.... actually I do not really work with graphics.... so I use Windows Paint Brush.... hehe

But I have photoshop too....

Thread #200326. Printed from Allegro.cc