Jump to content
  • Advertisement
Sign in to follow this  

SDL_WM_SetIcon strange bug

This topic is 4322 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone, I've been trying to change my Win32 application icon using SDL_WM_SetIcon() I'm using a 16x16 bitmap, 256 color image with colorkey for the application icon. Application icon actually got displayed but strangely, there some strange black pixels behind the displayed icon. I've tried many ways, repeatedly check and use different application icon but they always have this weird black pixels behind them. Application icon with colorkey, without mask ( mask = NULL ) http://img.photobucket.com/albums/v484/cizcuz/AppIcon2.png In one of my attempt, I've tried to setup a mask containing all zeros (which supposedly resulting application icon doesnt get displayed at all), Surprisingly it's still displaying the strange black pixels even with empty mask. Icon with mask of all zeros http://img.photobucket.com/albums/v484/cizcuz/AppIcon.png Anyone has any idea about the problem ? Here is the source code :
int main( int argc, char* args[] )

  //Start SDL

  SDL_Surface *iconSfc = SDL_LoadBMP( "data\\appicon.bmp" );
  SDL_SetColorKey( iconSfc, SDL_SRCCOLORKEY, 0 );

  char mask[ 16*16/8 ];
  memset( mask, 0, sizeof(mask) );
  SDL_WM_SetIcon( iconSfc, (Uint8*)mask );
  //SDL_WM_SetIcon( iconSfc, NULL );

  SDL_SetVideoMode( 640, 480, 32, 0 );

  BOOL bExit = FALSE;
  SDL_Event curEvent;

  while( !bExit ) {

    while (SDL_PollEvent (&curEvent)) {
        if( curEvent.type == SDL_QUIT ) {
            bExit = TRUE;
        else {
             /// Handle the event
         HandleSDLEvent( &curEvent );

  SDL_FreeSurface( iconSfc );

  //Quit SDL

  return 0;

Share this post

Link to post
Share on other sites
I've tried your code, created a bitmap (using GIMP) and it didn't applied transparency at all if it was 24bpp, then I converted it to 256 colors and the transparency was applied correctly with the COLORKEY method.

Could you put a link to the bmp you use?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!