IMG_jpg.c
changeset 117 e613cf987897
parent 109 0d1bd5675598
child 118 c5e736a47ad2
equal deleted inserted replaced
116:df32aeaf0b10 117:e613cf987897
    38 /*#define FAST_JPEG*/
    38 /*#define FAST_JPEG*/
    39 
    39 
    40 /* See if an image is contained in a data source */
    40 /* See if an image is contained in a data source */
    41 int IMG_isJPG(SDL_RWops *src)
    41 int IMG_isJPG(SDL_RWops *src)
    42 {
    42 {
       
    43 	int start;
    43 	int is_JPG;
    44 	int is_JPG;
    44 	Uint8 magic[4];
    45 	Uint8 magic[4];
    45 
    46 
       
    47 	start = SDL_RWtell(src);
    46 	is_JPG = 0;
    48 	is_JPG = 0;
    47 	if ( SDL_RWread(src, magic, 2, 1) ) {
    49 	if ( SDL_RWread(src, magic, 2, 1) ) {
    48 		if ( (magic[0] == 0xFF) && (magic[1] == 0xD8) ) {
    50 		if ( (magic[0] == 0xFF) && (magic[1] == 0xD8) ) {
    49 			SDL_RWread(src, magic, 4, 1);
    51 			SDL_RWread(src, magic, 4, 1);
    50 
    52 
    59 			     memcmp((char *)magic, "VVL", 3) == 0 ) {
    61 			     memcmp((char *)magic, "VVL", 3) == 0 ) {
    60 				is_JPG = 1;
    62 				is_JPG = 1;
    61 			}
    63 			}
    62 		}
    64 		}
    63 	}
    65 	}
       
    66 	SDL_RWseek(src, start, SEEK_SET);
    64 	return(is_JPG);
    67 	return(is_JPG);
    65 }
    68 }
    66 
    69 
    67 #define INPUT_BUFFER_SIZE	4096
    70 #define INPUT_BUFFER_SIZE	4096
    68 typedef struct {
    71 typedef struct {