[SDL] Blitting through an Intermediary
s_ridenour at kewlpc.org
Mon Apr 26 17:45:13 PDT 2004
According to the SDL docs, blitting a surface with an alpha channel to another
surface with an alpha channel doesn't alter the alpha channel of the
destination surface. So, even after the blitting is done, the destination
surface will still have its old alpha channel. That's why what you're trying
to do doesn't work.
I honestly have no idea why the destination alpha channel doesn't get modified
along with the destination color channels. Can Sam or anybody else please
explain the reason?
> I am using one png file (with alpha) to hold several images belonging to a
> I have a sprite class which I would like to have a function returning a
> surface corresponding to a given request.
> My attempt at this has been calling SDL_CreateRGBSurface(…) with the
> default options as presented in the documentation.
> I then blit to this surface and return it. On the upper level now I blit
> this temporary surface to the screen.
> The result is simple: nothing appears.
> If I set the amask to 0 I get a black box, but any other value (including
> default 0x000000ff) seems does nothing.
> Every SDL command I call returns success.
> Some relevant code:
> image = IMG_Load_RW( SDL_RWFromFile( imageFile, "rb" ), 1 );
> temp = SDL_CreateRGBSurface(SDL_HWSURFACE,
> 40,80,32,rmask,gmask,bmask,amask); …
> src.w = 40;
> src.h = 80;
> src.x = 40*i;
> src.y = 80*j;
> dst.x = 0;
> dst.y = 0;
> SDL_BlitSurface( image, &src, temp, &dst );
> (passed up)
> dst.x = 2;
> dst.y = 2;
> SDL_BlitSurface( temp, NULL, target, &dst );
> Where “target” is the screen.
> Other blits going from File -> Surface -> Display work with alpha.
> (As oppose to this File -> Surface -> Surface -> Display)
> I’ve removed all my error checking and obviously quite a bit of other code,
> but this is everything involving SDL calls.
> The sprite is currently 40x80 pixels,and the png file holds 3x3 images.
More information about the SDL