IMG_tif.c
changeset 117 e613cf987897
parent 98 9f94c4674cc9
child 118 c5e736a47ad2
equal deleted inserted replaced
116:df32aeaf0b10 117:e613cf987897
    75 	return size;
    75 	return size;
    76 }
    76 }
    77 
    77 
    78 int IMG_isTIF(SDL_RWops* src)
    78 int IMG_isTIF(SDL_RWops* src)
    79 {
    79 {
       
    80 	int start;
       
    81 	int is_TIF;
    80 	TIFF* tiff;
    82 	TIFF* tiff;
    81 	TIFFErrorHandler prev_handler;
    83 	TIFFErrorHandler prev_handler;
       
    84 
       
    85 	start = SDL_RWtell(src);
       
    86 	is_TIF = 0;
    82 
    87 
    83 	/* Suppress output from libtiff */
    88 	/* Suppress output from libtiff */
    84 	prev_handler = TIFFSetErrorHandler(NULL);
    89 	prev_handler = TIFFSetErrorHandler(NULL);
    85 	
    90 	
    86 	/* Attempt to process the given file data */
    91 	/* Attempt to process the given file data */
    90 
    95 
    91 	/* Reset the default error handler, since it can be useful for info */
    96 	/* Reset the default error handler, since it can be useful for info */
    92 	TIFFSetErrorHandler(prev_handler);
    97 	TIFFSetErrorHandler(prev_handler);
    93 
    98 
    94 	/* If it's not a TIFF, then tiff will be NULL. */
    99 	/* If it's not a TIFF, then tiff will be NULL. */
    95 	if(!tiff)
   100 	if ( tiff ) {
    96 		return 0;
   101 		is_TIF = 1;
    97 
   102 
    98 	/* Free up any dynamically allocated memory libtiff uses */
   103 		/* Free up any dynamically allocated memory libtiff uses */
    99 	TIFFClose(tiff);
   104 		TIFFClose(tiff);
   100 	
   105 	}
   101 	return 1;
   106 	SDL_RWseek(src, start, SEEK_SET);
       
   107 	return(is_TIF);
   102 }
   108 }
   103 
   109 
   104 SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src)
   110 SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src)
   105 {
   111 {
   106 	TIFF* tiff;
   112 	TIFF* tiff;