Search code examples
csdl

SDL_BlitSurface always blurry. What am I doing wrong?


With my code, I simply want to display a png-image on the screen using SDL 1.2.15, no scaling involved. However, the image shown on the screen with the code below always comes out blurry and the colors are off (see attached image). What am I doing wrong?

SDL_Init(SDL_INIT_VIDEO);
SDL_Surface *screen = SDL_SetVideoMode(400, 240, 24, SDL_HWSURFACE);
SDL_Surface *image = IMG_Load ( "/image.png" );
SDL_BlitSurface ( image, NULL, screen, NULL );
SDL_Flip(screen);

The image below shows the original image within the grey box (enlarged - each black stripe is one pixel wide, original dimensions are 11x11px) on the left and what the screen shows after executing the code above on the right.

enter image description here


Solution

  • The issue was SDL implementation platform specific and thus not valid for SDL in general