IMG_xpm.c
changeset 117 e613cf987897
parent 98 9f94c4674cc9
child 118 c5e736a47ad2
equal deleted inserted replaced
116:df32aeaf0b10 117:e613cf987897
    55 #ifdef LOAD_XPM
    55 #ifdef LOAD_XPM
    56 
    56 
    57 /* See if an image is contained in a data source */
    57 /* See if an image is contained in a data source */
    58 int IMG_isXPM(SDL_RWops *src)
    58 int IMG_isXPM(SDL_RWops *src)
    59 {
    59 {
       
    60 	int start;
       
    61 	int is_XPM;
    60 	char magic[9];
    62 	char magic[9];
    61 
    63 
    62 	return (SDL_RWread(src, magic, sizeof(magic), 1)
    64 	start = SDL_RWtell(src);
    63 		&& memcmp(magic, "/* XPM */", 9) == 0);
    65 	is_XPM = 0;
       
    66 	if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
       
    67 		if ( memcmp(magic, "/* XPM */", sizeof(magic)) == 0 ) {
       
    68 			is_XPM = 1;
       
    69 		}
       
    70 	}
       
    71 	SDL_RWseek(src, start, SEEK_SET);
       
    72 	return(is_XPM);
    64 }
    73 }
    65 
    74 
    66 /* Hash table to look up colors from pixel strings */
    75 /* Hash table to look up colors from pixel strings */
    67 #define STARTING_HASH_SIZE 256
    76 #define STARTING_HASH_SIZE 256
    68 
    77