IMG_gif.c
changeset 117 e613cf987897
parent 97 e1161bd417c4
child 118 c5e736a47ad2
equal deleted inserted replaced
116:df32aeaf0b10 117:e613cf987897
    32 #ifdef LOAD_GIF
    32 #ifdef LOAD_GIF
    33 
    33 
    34 /* See if an image is contained in a data source */
    34 /* See if an image is contained in a data source */
    35 int IMG_isGIF(SDL_RWops *src)
    35 int IMG_isGIF(SDL_RWops *src)
    36 {
    36 {
       
    37 	int start;
    37 	int is_GIF;
    38 	int is_GIF;
    38 	char magic[6];
    39 	char magic[6];
    39 
    40 
       
    41 	start = SDL_RWtell(src);
    40 	is_GIF = 0;
    42 	is_GIF = 0;
    41 	if ( SDL_RWread(src, magic, 6, 1) ) {
    43 	if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
    42 		if ( (strncmp(magic, "GIF", 3) == 0) &&
    44 		if ( (strncmp(magic, "GIF", 3) == 0) &&
    43 		     ((memcmp(magic + 3, "87a", 3) == 0) ||
    45 		     ((memcmp(magic + 3, "87a", 3) == 0) ||
    44 		      (memcmp(magic + 3, "89a", 3) == 0)) ) {
    46 		      (memcmp(magic + 3, "89a", 3) == 0)) ) {
    45 			is_GIF = 1;
    47 			is_GIF = 1;
    46 		}
    48 		}
    47 	}
    49 	}
       
    50 	SDL_RWseek(src, start, SEEK_SET);
    48 	return(is_GIF);
    51 	return(is_GIF);
    49 }
    52 }
    50 
    53 
    51 /* Code from here to end of file has been adapted from XPaint:           */
    54 /* Code from here to end of file has been adapted from XPaint:           */
    52 /* +-------------------------------------------------------------------+ */
    55 /* +-------------------------------------------------------------------+ */