IMG_png.c
changeset 117 e613cf987897
parent 100 3feaaa4104f6
child 118 c5e736a47ad2
     1.1 --- a/IMG_png.c	Sat Feb 04 04:53:36 2006 +0000
     1.2 +++ b/IMG_png.c	Sat Feb 04 20:37:17 2006 +0000
     1.3 @@ -76,14 +76,17 @@
     1.4  /* See if an image is contained in a data source */
     1.5  int IMG_isPNG(SDL_RWops *src)
     1.6  {
     1.7 -   unsigned char buf[PNG_BYTES_TO_CHECK];
     1.8 +	int start;
     1.9 +	int is_PNG;
    1.10 +	unsigned char buf[PNG_BYTES_TO_CHECK];
    1.11  
    1.12 -   /* Read in the signature bytes */
    1.13 -   if (SDL_RWread(src, buf, 1, PNG_BYTES_TO_CHECK) != PNG_BYTES_TO_CHECK)
    1.14 -      return 0;
    1.15 -
    1.16 -   /* Compare the first PNG_BYTES_TO_CHECK bytes of the signature. */
    1.17 -   return( !png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK));
    1.18 +	start = SDL_RWtell(src);
    1.19 +	is_PNG = 0;
    1.20 +	if ( SDL_RWread(src, buf, 1, PNG_BYTES_TO_CHECK) == PNG_BYTES_TO_CHECK ) {
    1.21 +		is_PNG = (png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK) == 0);
    1.22 +	}
    1.23 +	SDL_RWseek(src, start, SEEK_SET);
    1.24 +	return(is_PNG);
    1.25  }
    1.26  
    1.27  /* Load a PNG type image from an SDL datasource */