I’ve enclosed a test program (and cooresponding image file). It requires SDL
and the SDL_Image library.
I’ve been trying to blit a 6096x48x24 TGA image on to the screen. If I blit
directly to the screen, everything is fine, but if I try to blit to a proxy
surface in the video memory, and then blit from there to the screen, the
picture is garbled. It appears that cooresponding lines are not being copied
correctly and wrapping is occuring. Why is this happening, and what can I do
to avoid it? Thanks.
- Ithil
#include <stdlib.h>
#include <stdio.h>
#include “SDL/SDL.h”
#include “SDL/SDL_image.h”
#define for if(0);else for
int main(int argc, char **argv)
{
atexit (SDL_Quit);
if(SDL_Init(SDL_INIT_VIDEO) == -1)
{
printf(“Could not initialize SDL: %s.\n”, SDL_GetError());
exit (EXIT_FAILURE);
}
SDL_ShowCursor (0);
SDL_Surface *screen =
SDL_SetVideoMode (1024, 768, 32, SDL_HWSURFACE |
SDL_FULLSCREEN | SDL_DOUBLEBUF);
SDL_Surface *bitmap = IMG_Load (“bunker_l.tga”);
SDL_Surface *thing =
SDL_CreateRGBSurface (SDL_HWSURFACE, bitmap->w, bitmap->h, 32,
bitmap->format->Rmask, bitmap->format->Gmask,
bitmap->format->Bmask, bitmap->format->Amask);
SDL_BlitSurface (bitmap, NULL, thing, NULL);
SDL_DisplayFormat (thing);
SDL_FillRect (screen, NULL, 0);
SDL_BlitSurface (thing, NULL, screen, NULL);
SDL_Flip (screen);
SDL_Delay (3000);
SDL_FreeSurface (screen);
SDL_FreeSurface (thing);
SDL_FreeSurface (bitmap);
exit(EXIT_SUCCESS);
}