IMG_pcx.c
changeset 117 e613cf987897
parent 98 9f94c4674cc9
child 118 c5e736a47ad2
equal deleted inserted replaced
116:df32aeaf0b10 117:e613cf987897
    62 };
    62 };
    63 
    63 
    64 /* See if an image is contained in a data source */
    64 /* See if an image is contained in a data source */
    65 int IMG_isPCX(SDL_RWops *src)
    65 int IMG_isPCX(SDL_RWops *src)
    66 {
    66 {
       
    67 	int start;
    67 	int is_PCX;
    68 	int is_PCX;
    68 	const int ZSoft_Manufacturer = 10;
    69 	const int ZSoft_Manufacturer = 10;
    69 	const int PC_Paintbrush_Version = 5;
    70 	const int PC_Paintbrush_Version = 5;
    70 	const int PCX_RunLength_Encoding = 1;
    71 	const int PCX_RunLength_Encoding = 1;
    71 	struct PCXheader pcxh;
    72 	struct PCXheader pcxh;
    72 
    73 
       
    74 	start = SDL_RWtell(src);
    73 	is_PCX = 0;
    75 	is_PCX = 0;
    74 	if ( SDL_RWread(src, &pcxh, sizeof(pcxh), 1) == 1 ) {
    76 	if ( SDL_RWread(src, &pcxh, sizeof(pcxh), 1) == 1 ) {
    75 		if ( (pcxh.Manufacturer == ZSoft_Manufacturer) &&
    77 		if ( (pcxh.Manufacturer == ZSoft_Manufacturer) &&
    76 		     (pcxh.Version == PC_Paintbrush_Version) &&
    78 		     (pcxh.Version == PC_Paintbrush_Version) &&
    77 		     (pcxh.Encoding == PCX_RunLength_Encoding) ) {
    79 		     (pcxh.Encoding == PCX_RunLength_Encoding) ) {
    78 			is_PCX = 1;
    80 			is_PCX = 1;
    79 		}
    81 		}
    80 	}
    82 	}
       
    83 	SDL_RWseek(src, start, SEEK_SET);
    81 	return(is_PCX);
    84 	return(is_PCX);
    82 }
    85 }
    83 
    86 
    84 /* Load a PCX type image from an SDL datasource */
    87 /* Load a PCX type image from an SDL datasource */
    85 SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src)
    88 SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src)