I planned to do it with SDL_DisplayOverlay in order to scale it, is it possible.
I can't see the the whole bmp, I appreciate any suggestion on this.
Here is the code:
- Code: Select all
SDL_Surface* screen = SDL_SetVideoMode(800, 400, 16,SDL_HWSURFACE|SDL_DOUBLEBUF);
// load an image
SDL_Surface* bmp = SDL_LoadBMP("cb.bmp");
if (!bmp)
{
printf("Unable to load bitmap: %s\n", SDL_GetError());
return 1;
}
SDL_Overlay *overlay = NULL;
// centre the bitmap on screen
SDL_Rect dstrect;
dstrect.x = 0;
dstrect.y = 0;
// program main loop
bool done = false;
while (!done)
{
// message processing loop
SDL_Event event;
while (SDL_PollEvent(&event))
{
// check for messages
switch (event.type)
{
// exit if the window is closed
case SDL_QUIT:
done = true;
break;
// check for keypresses
case SDL_KEYDOWN:
{
// exit if ESCAPE is pressed
if (event.key.keysym.sym == SDLK_ESCAPE)
done = true;
break;
}
} // end switch
} // end of message processing
// DRAWING STARTS HERE
// clear screen
SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
// draw bitmap
SDL_BlitSurface(bmp, 0, screen, &dstrect);
overlay = SDL_CreateYUVOverlay(bmp->w,bmp->h, SDL_IYUV_OVERLAY , screen);
SDL_Rect video_rect;
video_rect.x = 0;
video_rect.y = 0;
video_rect.w = screen->w;
video_rect.h = screen->h;
SDL_DisplayYUVOverlay(overlay, &video_rect);
// DRAWING ENDS HERE
// finally, update the screen :)
//SDL_Flip(screen);
} // end main loop
Thanks and regards
kovicic

