Inconsistent behaviour from SDL_BlitSurface
- by bardes
Here is an example code:
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <stdio.h>
int main()
{
if(SDL_Init(SDL_INIT_EVERYTHING) == -1)
{
printf("SDL ERROR: %s", SDL_GetError());
return 1;
}
SDL_Surface *screen;
screen = SDL_SetVideoMode(128, 128, 32, SDL_SWSURFACE);
SDL_Surface *img;
img = IMG_Load("./debug.png");
SDL_BlitSurface(img, NULL, screen, NULL);
SDL_Flip(screen);
SDL_Delay(1000);
SDL_FreeSurface(img);
SDL_Quit();
return 0;
}
It compiles fine, but when I run it sometimes it works and most times only part of the image is displayed. I really can't imagine what's causing that...
EDIT:
This is the image I'm using to test the program: http://img140.imageshack.us/img140/3858/debugi.png