1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#include <stdio.h>
#include <SDL.h>
#include <SDL_image.h>
int main(int argc, char **argv)
{
int exited=0;
SDL_Surface *screen, *image;
SDL_Rect rect;
if(SDL_Init(SDL_INIT_VIDEO)<0){
fprintf(stderr,"Problem loading movie.",
SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
screen=SDL_SetVideoMode(640,480,16,SDL_SWSURFACE);
if(screen==NULL){
fprintf(stderr,"Couldn't set video mode: %s\n",
SDL_GetError());
exit(1);
}
image=IMG_Load("Frame1.jpg");
if(image==NULL){
fprintf(stderr,"Couldn't load movie\n");
exit(1);
}
if(SDL_SetColorKey(image,SDL_RLEACCEL,SDL_MapRGB(image->format,0,0,0))){
fprintf(stderr,"Couldn't ser color key: %s\n",SDL_GetError());
exit(1);
}
image=SDL_DisplayFormat(image);
rect.x=100;rect.y=100;rect.w=image->w;rect.h=image->h;
SDL_BlitSurface(image,0,screen,&rect);
SDL_UpdateRects(screen,1,&rect);
while(exited==0){
SDL_Event event;
if(SDL_PollEvent(&event)==1){
if((event.type==SDL_KEYDOWN &&
event.key.keysym.sym==SDLK_ESCAPE) ||
(event.type==SDL_QUIT))exited=1;
}
}
return 0;
}
|