Showing a 8 bit bmp to the screen with SDL

Hi experts,
I would like to show the image of finger print which is a 8 bit monochrome on the MFC application
with Libsdl
here is the code I use :slight_smile:

SDL_Window*		GWindow = NULL;
SDL_Surface*	GScreenSurface = NULL;
SDL_Surface*	GHelloWorld = NULL;
//////////////////////////////////////////////////////
GWindow = SDL_CreateWindowFrom((void *)(GetDlgItem(IDC_STATIC_PIC1)->GetSafeHwnd()));
if (GWindow == NULL)
{
	//char bufffer[256];
	//sprintf(bufffer, "SDL_Error:could not be created Window!%s\n", SDL_GetError());
	return;
}
GScreenSurface = SDL_GetWindowSurface(GWindow);
std::string m_savePath = "d:\\finger.bmp";
GHelloWorld = SDL_LoadBMP(m_savePath.c_str());//loading picture  
if (GHelloWorld == NULL)
{
	printf("Unable to load image %s SDL Error:%s\n ", "Hello_World.bmp", SDL_GetError());
	return;
}
SDL_Rect stretchRect;
stretchRect.x = 0;
stretchRect.y = 0;
stretchRect.w = GScreenSurface->w;
stretchRect.h = GScreenSurface->h;
SDL_BlitScaled(GHelloWorld, NULL, GScreenSurface, &stretchRect);
SDL_UpdateWindowSurface(GWindow); // copy the window surface to update the screen.

But only a black screen is displayed.

could you please tell me how to tune libsdl to show 8 bit monochrome images.

Thanks a lot.

Maybe you need to poll events:

int quit = 0;
 while(!quit)
  {
    SDL_Event e;
    while(SDL_PollEvent(&e)) {
      switch(e.type) {
        case SDL_QUIT:
          quit = 1;
          break;
      }  
     ... 
      SDL_UpdateWindowSurface(GWindow); // copy the window surface to update the screen.
    }

hi, you could try

SDL_SetSurfaceBlendMode(GHelloWorld, SDL_BLENDMODE_NONE);

If this doesnโ€™t work, try first to convert your image into a more usual color format