The perfect transparent surface. ( Improved question )

Miguel Pragier <pragier gmail.com> writes:

What’s the?better way to create a 100% transparent surface?
?
If exist a kind of 'design pattern" to create transparent surfaces, can
anyone point me a code sample?
?
And can anyone tell me?any information?about the color masks?
?


SDL mailing list
SDL lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

What’s the best SDL’s way to create a 800x600 32Bpp surface 100% transparent?

I know the SDL_CreateRGBSurface, but don’t know much about the color mask.
specially the AMask.

Thank you, everybody.

El Monday 05 November 2007 17:58:21 Miguel Pragier escribi?:

What’s the?better way to create a 100% transparent surface?
?
If exist a kind of 'design pattern" to create transparent surfaces, can

anyone point me a code sample?

?
And can anyone tell me?any information?about the color masks?

What’s the best SDL’s way to create a 800x600 32Bpp surface 100%
transparent?

I know the SDL_CreateRGBSurface, but don’t know much about the color mask.
specially the AMask.

Every mask is the binary mask that specify where its colour component is
stored. From the documentation example:

SDL_Surface *surface;
Uint32 rmask, gmask, bmask, amask;

/* SDL interprets each pixel as a 32-bit number, so our masks must depend
   on the endianness (byte order) of the machine */

#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
#else
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
#endif

surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,
                               rmask, gmask, bmask, amask);

What do you mean by 100% transparent? Invisible?

Alberto Luaces <aluaces udc.es> writes:

Every mask is the binary mask that specify where its colour component is
stored.

surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,
                               rmask, gmask, bmask, amask);

What do you mean by 100% transparent? Invisible?

Yes. Invisible.
I’m going to try some masks combinations.

Thank you for now, Mr. Luaces.

El Tuesday 06 November 2007 13:04:20 Miguel Pragier escribi?:

Every mask is the binary mask that specify where its colour component is
stored.

? ? surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?rmask, gmask, bmask, amask);

What do you mean by 100% transparent? Invisible?

Yes. Invisible.

Sorry if I do not fully understand you, but if you are going to blit an
invisible surface, why bother to try to display it at all?

I’m going to try some masks combinations.

If you are using Windows your pixel format will be tipically RGBA, 8 bits for
every of the four components, stored in little endian format. However it is
better to do as the example shown in the documentation and mind the endianess
of your system.

My intention is to create the invisible surface, and, over this, to blit.
Is the same as draw over a transparent paper. :slight_smile:

2007/11/6, Alberto Luaces :>

El Tuesday 06 November 2007 13:04:20 Miguel Pragier escribi?:

Every mask is the binary mask that specify where its colour component
is

stored.

surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,
rmask, gmask, bmask, amask);

What do you mean by 100% transparent? Invisible?

Yes. Invisible.

Sorry if I do not fully understand you, but if you are going to blit an
invisible surface, why bother to try to display it at all?

I’m going to try some masks combinations.

If you are using Windows your pixel format will be tipically RGBA, 8 bits
for
every of the four components, stored in little endian format. However it
is
better to do as the example shown in the documentation and mind the
endianess
of your system.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

El Wednesday 07 November 2007 13:10:03 Miguel Pragier escribi?:

My intention is to create the invisible surface, and, over this, to blit.
Is the same as draw over a transparent paper. :slight_smile:

Then it will be useful to use

int SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha);

with your transparent surface. Keep in mind what is said in the documentation:

“0 (SDL_ALPHA_TRANSPARENT) is now considered transparent.”> 2007/11/6, Alberto Luaces <@Alberto_Luaces_Ferna>:

El Tuesday 06 November 2007 13:04:20 Miguel Pragier escribi?:

Every mask is the binary mask that specify where its colour component

is

stored.

surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,
rmask, gmask, bmask, amask);

What do you mean by 100% transparent? Invisible?

Yes. Invisible.

Sorry if I do not fully understand you, but if you are going to blit an
invisible surface, why bother to try to display it at all?

I’m going to try some masks combinations.

If you are using Windows your pixel format will be tipically RGBA, 8 bits
for
every of the four components, stored in little endian format. However it
is
better to do as the example shown in the documentation and mind the
endianess
of your system.