Hi,
I would like to load several transparent images (PNG) and blit
them on a surface. Then this surface will be blitted on the
screen. (Instead of having to blit everytime all the PNGs with
their positions directly to the screen)
I’m not able to do it… the intermediate surface is all black
or don’t show uo at all. If I blit the images directly on the
screen, everything is all right. I’ve tried a small program to
reproduce what I need :
/********************************************************/ SDL_Init(SDL_INIT_VIDEO); SDL_Surface *screen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE); SDL_Surface *img = IMG_Load("alpha1.png"); SDL_Surface *temp = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, img->w, img->h, 16, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000); SDL_Rect rect = {0, img->h, 0, 0}; SDL_FillRect(screen, NULL, 7000); // Blit the PNG on the intermediate surface SDL_BlitSurface(img, NULL, temp, NULL); // Blit the intermediate surface on the screen SDL_BlitSurface(temp, NULL, screen, NULL); // Blit the PNG on the screen below the intermediate surface SDL_BlitSurface(img, NULL, screen, &rect); /* we don't have the same results :( */ SDL_UpdateRect(screen, 0, 0, 0, 0); SDL_Delay(2000); SDL_FreeSurface(img); SDL_FreeSurface(temp); SDL_Quit(); /********************************************************/
Any suggestions ?