I am trying to load bmp file that has alpha channel, but I am not getting expected result on the screen. Image is displayed but alpha channel information is ignored. Am I doing something wrong, or alpha bmp’s are not supported in current SDL version?
Code goes something like this (for the clarity I have omitted error checking):
Code:
// init
SDL_Init( SDL_INIT_VIDEO);
SDL_Surface* screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BITSPERPIXEL, SDL_HWSURFACE | SDL_DOUBLEBUF);
// clear screen
SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 128, 128, 128));
// load bmp that has alpha chanel (32 bit/pixel)
SDL_Surface* bmp = SDL_LoadBMP(“alpha.bmp”);
// set flag for alpha channnel
SDL_SetAlpha(bmp, SDL_SRCALPHA /| SDL_RLEACCEL/, SDL_ALPHA_OPAQUE);
// show it
SDL_BlitSurface(bmp, 0, screen, 0);
SDL_Flip(screen);
SDL_FreeSurface(bmp);
Thanks!