IMG_bmp.c
changeset 117 e613cf987897
parent 106 65e8cd587119
child 118 c5e736a47ad2
equal deleted inserted replaced
116:df32aeaf0b10 117:e613cf987897
    32 #ifdef LOAD_BMP
    32 #ifdef LOAD_BMP
    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_isBMP(SDL_RWops *src)
    35 int IMG_isBMP(SDL_RWops *src)
    36 {
    36 {
       
    37 	int start;
    37 	int is_BMP;
    38 	int is_BMP;
    38 	char magic[2];
    39 	char magic[2];
    39 
    40 
       
    41 	start = SDL_RWtell(src);
    40 	is_BMP = 0;
    42 	is_BMP = 0;
    41 	if ( SDL_RWread(src, magic, 2, 1) ) {
    43 	if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
    42 		if ( strncmp(magic, "BM", 2) == 0 ) {
    44 		if ( strncmp(magic, "BM", 2) == 0 ) {
    43 			is_BMP = 1;
    45 			is_BMP = 1;
    44 		}
    46 		}
    45 	}
    47 	}
       
    48 	SDL_RWseek(src, start, SEEK_SET);
    46 	return(is_BMP);
    49 	return(is_BMP);
    47 }
    50 }
    48 
    51 
    49 #include "SDL_error.h"
    52 #include "SDL_error.h"
    50 #include "SDL_video.h"
    53 #include "SDL_video.h"