Showing a 8 bit bmp to the screen with SDL


#1

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.