About Amask and AlphaValues

hi,

I need some help.

  1. I would like to know why I get -16777216 from SDL_Surface
    *surface->format->Amask and what can I do with that ?

  2. where is the pointer to the alphavalues ?

Thanks

Laurent_________________________________________________________________
Discutez en ligne avec vos amis, essayez MSN Messenger?:
http://messenger.msn.fr

“atelier3w Laurent” wrote in message
news:mailman.1015412885.23984.sdl at libsdl.org

hi,

I need some help.

  1. I would like to know why I get -16777216 from SDL_Surface
    *surface->format->Amask

You don’t. ‘Amask’ is unsigned, so it can never have a negative
value.

and what can I do with that ?

Whatever you want. :slight_smile:

  1. where is the pointer to the alphavalues ?

Alpha values are interleaved with RGB values.

Uint32 map_rgba(SDL_PixelFormat const *fmt, Uint8 r, Uint8 g, Uint8 b,
Uint8 a)
{
Uint32 c = 0;
c |= ((((Uint32)r) >> fmt->Rloss) << fmt->Rshift) & fmt->Rmask;
c |= ((((Uint32)g) >> fmt->Gloss) << fmt->Gshift) & fmt->Gmask;
c |= ((((Uint32)b) >> fmt->Bloss) << fmt->Bshift) & fmt->Bmask;
c |= ((((Uint32)a) >> fmt->Aloss) << fmt->Ashift) & fmt->Amask;
}

void set_pixel(SDL_Surface s, int x, int y, Uint8 r, Uint8 g, Uint8
b, Uint8 a)
{
assert(s->BytesPerPixel == 4);
/
Assume the surface is already locked */
Uint32 *line_ptr = (Uint32 *)((char *)s->pixels + y * s->pitch);
line_ptr[x] = map_rgba(s->fmt, r, g, b, a);
}

These functions are provided for demonstration purposes only, and
should never be used in real code. SDL already provides 'SDL_MapRGBA’
with the same semantics as ‘map_rgba’ above.–
Rainer Deyke | root at rainerdeyke.com | http://rainerdeyke.com