Strange application icon problem

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

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 )

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

Icon with mask of all zeros

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[ 1616/8 ];
memset( mask, 0, sizeof(mask) );
SDL_WM_SetIcon( iconSfc, (Uint8
)mask );
//SDL_WM_SetIcon( iconSfc, NULL );

SDL_SetVideoMode( 640, 480, 32, 0 );

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;