Date: Tue, 24 Apr 2001 15:26:53 +0200 (MET DST)
authorSam Lantinga <slouken@lokigames.com>
Sat, 28 Apr 2001 18:24:37 +0000
changeset 354b1f174486fa
parent 34 26723f72c583
child 36 a44c9e27fa6e
Date: Tue, 24 Apr 2001 15:26:53 +0200 (MET DST)
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Subject: XPM patch to SDL_image

A couple of people have requested an interface to SDL_image for loading
SDL images directly from #included XPM files in the C source.
Writing a separate loader for this would be silly as the code in SDL_image
already does the XPM parsing, so I added a new call to the SDL_image API:

SDL_Surface *IMG_ReadXPMFromArray(char **xpm);

which does the obvious thing. As a bonus, the code got a little cleaner as
well. (We probably need to increase the minor .so-version number since the
interface got changed but I didn't do so in my patch.)

We should perhaps include the rgb.txt colour name database as well, since
it's quite small (~13K in binary form), but I haven't made up my mind

Cheers,

Mattias
IMG.c
IMG_xpm.c
README
SDL_image.h
configure.in
showimage.c
     1.1 --- a/IMG.c	Fri Apr 06 03:27:14 2001 +0000
     1.2 +++ b/IMG.c	Sat Apr 28 18:24:37 2001 +0000
     1.3 @@ -68,7 +68,7 @@
     1.4  }
     1.5  
     1.6  /* Portable case-insensitive string compare function */
     1.7 -int IMG_string_equals(const char *str1, const char *str2)
     1.8 +static int IMG_string_equals(const char *str1, const char *str2)
     1.9  {
    1.10  	while ( *str1 && *str2 ) {
    1.11  		if ( toupper((unsigned char)*str1) !=
     2.1 --- a/IMG_xpm.c	Fri Apr 06 03:27:14 2001 +0000
     2.2 +++ b/IMG_xpm.c	Sat Apr 28 18:24:37 2001 +0000
     2.3 @@ -22,7 +22,28 @@
     2.4      slouken@devolution.com
     2.5  */
     2.6  
     2.7 -/* This is an XPM image file loading framework */
     2.8 +/*
     2.9 + * XPM (X PixMap) image loader:
    2.10 + *
    2.11 + * Supports the XPMv3 format, EXCEPT:
    2.12 + * - hotspot coordinates are ignored
    2.13 + * - only colour ('c') colour symbols are used
    2.14 + * - rgb.txt is not used (for portability), so only RGB colours
    2.15 + *   are recognized (#rrggbb etc) - only a few basic colour names are
    2.16 + *   handled
    2.17 + *
    2.18 + * The result is an 8bpp indexed surface if possible, otherwise 32bpp.
    2.19 + * The colourkey is correctly set if transparency is used.
    2.20 + * 
    2.21 + * Besides the standard API, also provides
    2.22 + *
    2.23 + *     SDL_Surface *IMG_ReadXPMFromArray(char **xpm)
    2.24 + *
    2.25 + * that reads the image data from an XPM file included in the C source.
    2.26 + *
    2.27 + * TODO: include rgb.txt here. The full table (from solaris 2.6) only
    2.28 + * requires about 13K in binary form.
    2.29 + */
    2.30  
    2.31  #include <stdlib.h>
    2.32  #include <stdio.h>
    2.33 @@ -36,41 +57,10 @@
    2.34  /* See if an image is contained in a data source */
    2.35  int IMG_isXPM(SDL_RWops *src)
    2.36  {
    2.37 -	int is_XPM;
    2.38 -	char magic[10];
    2.39 +	char magic[9];
    2.40  
    2.41 -	is_XPM = 0;
    2.42 -	if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
    2.43 -		if(memcmp(magic, "/* XPM */", 9) == 0) {
    2.44 -			is_XPM = 1;
    2.45 -		}
    2.46 -	}
    2.47 -	return(is_XPM);
    2.48 -}
    2.49 -
    2.50 -static char *SDL_RWgets(char *string, int maxlen, SDL_RWops *src)
    2.51 -{
    2.52 -	int i;
    2.53 -
    2.54 -	for ( i=0; i<(maxlen-1); ++i ) {
    2.55 -		if ( SDL_RWread(src, &string[i], 1, 1) <= 0 ) {
    2.56 -			/* EOF or error */
    2.57 -			if ( i == 0 ) {
    2.58 -				/* Hmm, EOF on initial read, return NULL */
    2.59 -				return NULL;
    2.60 -			}
    2.61 -			break;
    2.62 -		}
    2.63 -		/* In this case it's okay to use either '\r' or '\n'
    2.64 -		   as line separators because blank lines are just
    2.65 -		   ignored by the XPM format.
    2.66 -		*/
    2.67 -		if ( (string[i] == '\n') || (string[i] == '\r') ) {
    2.68 -			break;
    2.69 -		}
    2.70 -	}
    2.71 -	string[i] = '\0';
    2.72 -	return(string);
    2.73 +	return (SDL_RWread(src, magic, sizeof(magic), 1)
    2.74 +		&& memcmp(magic, "/* XPM */", 9) == 0);
    2.75  }
    2.76  
    2.77  /* Hash table to look up colors from pixel strings */
    2.78 @@ -165,13 +155,26 @@
    2.79  	}
    2.80  }
    2.81  
    2.82 +/* portable case-insensitive string comparison */
    2.83 +static int string_equal(const char *a, const char *b, int n)
    2.84 +{
    2.85 +	while(*a && *b && n) {
    2.86 +		if(toupper((unsigned char)*a) != toupper((unsigned char)*b))
    2.87 +			return 0;
    2.88 +		a++;
    2.89 +		b++;
    2.90 +		n--;
    2.91 +	}
    2.92 +	return *a == *b;
    2.93 +}
    2.94 +
    2.95  #define ARRAYSIZE(a) (int)(sizeof(a) / sizeof((a)[0]))
    2.96  
    2.97  /*
    2.98   * convert colour spec to RGB (in 0xrrggbb format).
    2.99 - * return 1 if successful. may scribble on the colorspec buffer.
   2.100 + * return 1 if successful.
   2.101   */
   2.102 -static int color_to_rgb(char *spec, Uint32 *rgb)
   2.103 +static int color_to_rgb(char *spec, int speclen, Uint32 *rgb)
   2.104  {
   2.105  	/* poor man's rgb.txt */
   2.106  	static struct { char *name; Uint32 rgb; } known[] = {
   2.107 @@ -185,23 +188,22 @@
   2.108  
   2.109  	if(spec[0] == '#') {
   2.110  		char buf[7];
   2.111 -		++spec;
   2.112 -		switch(strlen(spec)) {
   2.113 -		case 3:
   2.114 -			buf[0] = buf[1] = spec[0];
   2.115 -			buf[2] = buf[3] = spec[1];
   2.116 -			buf[4] = buf[5] = spec[2];
   2.117 +		switch(speclen) {
   2.118 +		case 4:
   2.119 +			buf[0] = buf[1] = spec[1];
   2.120 +			buf[2] = buf[3] = spec[2];
   2.121 +			buf[4] = buf[5] = spec[3];
   2.122  			break;
   2.123 -		case 6:
   2.124 -			memcpy(buf, spec, 6);
   2.125 +		case 7:
   2.126 +			memcpy(buf, spec + 1, 6);
   2.127  			break;
   2.128 -		case 12:
   2.129 -			buf[0] = spec[0];
   2.130 -			buf[1] = spec[1];
   2.131 -			buf[2] = spec[4];
   2.132 -			buf[3] = spec[5];
   2.133 -			buf[4] = spec[8];
   2.134 -			buf[5] = spec[9];
   2.135 +		case 13:
   2.136 +			buf[0] = spec[1];
   2.137 +			buf[1] = spec[2];
   2.138 +			buf[2] = spec[5];
   2.139 +			buf[3] = spec[6];
   2.140 +			buf[4] = spec[9];
   2.141 +			buf[5] = spec[10];
   2.142  			break;
   2.143  		}
   2.144  		buf[6] = '\0';
   2.145 @@ -210,7 +212,7 @@
   2.146  	} else {
   2.147  		int i;
   2.148  		for(i = 0; i < ARRAYSIZE(known); i++)
   2.149 -			if(IMG_string_equals(known[i].name, spec)) {
   2.150 +			if(string_equal(known[i].name, spec, speclen)) {
   2.151  				*rgb = known[i].rgb;
   2.152  				return 1;
   2.153  			}
   2.154 @@ -218,51 +220,106 @@
   2.155  	}
   2.156  }
   2.157  
   2.158 -static char *skipspace(char *p)
   2.159 -{
   2.160 -	while(isspace((unsigned char)*p))
   2.161 -	      ++p;
   2.162 -	return p;
   2.163 -}
   2.164 -
   2.165 -static char *skipnonspace(char *p)
   2.166 -{
   2.167 -	while(!isspace((unsigned char)*p) && *p)
   2.168 -		++p;
   2.169 -	return p;
   2.170 -}
   2.171 -
   2.172  #ifndef MAX
   2.173  #define MAX(a, b) ((a) > (b) ? (a) : (b))
   2.174  #endif
   2.175  
   2.176 -/* Load a XPM type image from an SDL datasource */
   2.177 -SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src)
   2.178 +static char *linebuf;
   2.179 +static int buflen;
   2.180 +static char *error;
   2.181 +
   2.182 +/*
   2.183 + * Read next line from the source.
   2.184 + * If len > 0, it's assumed to be at least len chars (for efficiency).
   2.185 + * Return NULL and set error upon EOF or parse error.
   2.186 + */
   2.187 +char *get_next_line(char ***lines, SDL_RWops *src, int len)
   2.188  {
   2.189 -	SDL_Surface *image;
   2.190 -	char line[1024];
   2.191 -	char *here;
   2.192 +	if(lines) {
   2.193 +		return *(*lines)++;
   2.194 +	} else {
   2.195 +		char c;
   2.196 +		int n;
   2.197 +		do {
   2.198 +			if(SDL_RWread(src, &c, 1, 1) <= 0) {
   2.199 +				error = "Premature end of data";
   2.200 +				return NULL;
   2.201 +			}
   2.202 +		} while(c != '"');
   2.203 +		if(len) {
   2.204 +			len += 4;	/* "\",\n\0" */
   2.205 +			if(len > buflen){
   2.206 +				buflen = len;
   2.207 +				linebuf = realloc(linebuf, buflen);
   2.208 +				if(!linebuf) {
   2.209 +					error = "Out of memory";
   2.210 +					return NULL;
   2.211 +				}
   2.212 +			}
   2.213 +			if(SDL_RWread(src, linebuf, len - 1, 1) <= 0) {
   2.214 +				error = "Premature end of data";
   2.215 +				return NULL;
   2.216 +			}
   2.217 +			n = len - 2;
   2.218 +		} else {
   2.219 +			n = 0;
   2.220 +			do {
   2.221 +				if(n >= buflen - 1) {
   2.222 +					if(buflen == 0)
   2.223 +						buflen = 16;
   2.224 +					buflen *= 2;
   2.225 +					linebuf = realloc(linebuf, buflen);
   2.226 +					if(!linebuf) {
   2.227 +						error = "Out of memory";
   2.228 +						return NULL;
   2.229 +					}
   2.230 +				}
   2.231 +				if(SDL_RWread(src, linebuf + n, 1, 1) <= 0) {
   2.232 +					error = "Premature end of data";
   2.233 +					return NULL;
   2.234 +				}
   2.235 +			} while(linebuf[n++] != '"');
   2.236 +			n--;
   2.237 +		}
   2.238 +		linebuf[n] = '\0';
   2.239 +		return linebuf;
   2.240 +	}
   2.241 +}
   2.242 +
   2.243 +#define SKIPSPACE(p)				\
   2.244 +do {						\
   2.245 +	while(isspace((unsigned char)*(p)))	\
   2.246 +	      ++(p);				\
   2.247 +} while(0)
   2.248 +
   2.249 +#define SKIPNONSPACE(p)					\
   2.250 +do {							\
   2.251 +	while(!isspace((unsigned char)*(p)) && *p)	\
   2.252 +	      ++(p);					\
   2.253 +} while(0)
   2.254 +
   2.255 +/* read XPM from either array or RWops */
   2.256 +static SDL_Surface *load_xpm(char **xpm, SDL_RWops *src)
   2.257 +{
   2.258 +	SDL_Surface *image = NULL;
   2.259  	int index;
   2.260  	int x, y;
   2.261  	int w, h, ncolors, cpp;
   2.262 -	int pixels_len;
   2.263 -	char *pixels = NULL;
   2.264  	int indexed;
   2.265  	Uint8 *dst;
   2.266 -	struct color_hash *colors;
   2.267 +	struct color_hash *colors = NULL;
   2.268  	SDL_Color *im_colors = NULL;
   2.269 -	char *keystrings, *nextkey;
   2.270 -	char *error = NULL;
   2.271 +	char *keystrings = NULL, *nextkey;
   2.272 +	char *line;
   2.273 +	char ***xpmlines = NULL;
   2.274 +	int pixels_len;
   2.275  
   2.276 -	/* Skip to the first string, which describes the image */
   2.277 -	do {
   2.278 -	        here = SDL_RWgets(line, sizeof(line), src);
   2.279 -		if ( !here ) {
   2.280 -			IMG_SetError("Premature end of data");
   2.281 -			return(NULL);
   2.282 -		}
   2.283 -		here = skipspace(here);
   2.284 -	} while(*here != '"');
   2.285 +	if(xpm)
   2.286 +		xpmlines = &xpm;
   2.287 +
   2.288 +	line = get_next_line(xpmlines, src, 0);
   2.289 +	if(!line)
   2.290 +		goto done;
   2.291  	/*
   2.292  	 * The header string of an XPMv3 image has the format
   2.293  	 *
   2.294 @@ -272,17 +329,16 @@
   2.295  	 * Right now we don't use the hotspots but it should be handled
   2.296  	 * one day.
   2.297  	 */
   2.298 -	if(sscanf(here + 1, "%d %d %d %d", &w, &h, &ncolors, &cpp) != 4
   2.299 +	if(sscanf(line, "%d %d %d %d", &w, &h, &ncolors, &cpp) != 4
   2.300  	   || w <= 0 || h <= 0 || ncolors <= 0 || cpp <= 0) {
   2.301 -		IMG_SetError("Invalid format description");
   2.302 -		return(NULL);
   2.303 +		error = "Invalid format description";
   2.304 +		goto done;
   2.305  	}
   2.306  
   2.307  	keystrings = malloc(ncolors * cpp);
   2.308  	if(!keystrings) {
   2.309 -		IMG_SetError("Out of memory");
   2.310 -		free(pixels);
   2.311 -		return NULL;
   2.312 +		error = "Out of memory";
   2.313 +		goto done;
   2.314  	}
   2.315  	nextkey = keystrings;
   2.316  
   2.317 @@ -300,152 +356,111 @@
   2.318  	}
   2.319  	if(!image) {
   2.320  		/* Hmm, some SDL error (out of memory?) */
   2.321 -		free(pixels);
   2.322 -		return(NULL);
   2.323 +		goto done;
   2.324  	}
   2.325  
   2.326  	/* Read the colors */
   2.327  	colors = create_colorhash(ncolors);
   2.328 -	if ( ! colors ) {
   2.329 +	if (!colors) {
   2.330  		error = "Out of memory";
   2.331  		goto done;
   2.332  	}
   2.333  	for(index = 0; index < ncolors; ++index ) {
   2.334 -		char *key;
   2.335 -		int len;
   2.336 +		char *p;
   2.337 +		line = get_next_line(xpmlines, src, 0);
   2.338 +		if(!line)
   2.339 +			goto done;
   2.340  
   2.341 -		do {
   2.342 -			here = SDL_RWgets(line, sizeof(line), src);
   2.343 -			if(!here) {
   2.344 -				error = "Premature end of data";
   2.345 -				goto done;
   2.346 -			}
   2.347 -			here = skipspace(here);
   2.348 -		} while(*here != '"');
   2.349 -
   2.350 -		++here;
   2.351 -		len = strlen(here);
   2.352 -		if(len < cpp + 7)
   2.353 -			continue;	/* cannot be a valid line */
   2.354 -
   2.355 -		key = here;
   2.356 -		key[cpp] = '\0';
   2.357 -		here += cpp + 1;
   2.358 +		p = line + cpp + 1;
   2.359  
   2.360  		/* parse a colour definition */
   2.361  		for(;;) {
   2.362  			char nametype;
   2.363  			char *colname;
   2.364 -			char delim;
   2.365 -			Uint32 rgb;
   2.366 +			Uint32 rgb, pixel;
   2.367  
   2.368 -			here = skipspace(here);
   2.369 -			nametype = *here;
   2.370 -			here = skipnonspace(here);
   2.371 -			here = skipspace(here);
   2.372 -			colname = here;
   2.373 -			while(*here && !isspace((unsigned char)*here)
   2.374 -			      && *here != '"')
   2.375 -				here++;
   2.376 -			if(!*here) {
   2.377 -				error = "color parse error";
   2.378 +			SKIPSPACE(p);
   2.379 +			if(!*p) {
   2.380 +				error = "colour parse error";
   2.381  				goto done;
   2.382  			}
   2.383 +			nametype = *p;
   2.384 +			SKIPNONSPACE(p);
   2.385 +			SKIPSPACE(p);
   2.386 +			colname = p;
   2.387 +			SKIPNONSPACE(p);
   2.388  			if(nametype == 's')
   2.389  				continue;      /* skip symbolic colour names */
   2.390  
   2.391 -			delim = *here;
   2.392 -			*here = '\0';
   2.393 -			if(delim)
   2.394 -			    here++;
   2.395 -
   2.396 -			if(!color_to_rgb(colname, &rgb))
   2.397 +			if(!color_to_rgb(colname, p - colname, &rgb))
   2.398  				continue;
   2.399  
   2.400 -			memcpy(nextkey, key, cpp);
   2.401 +			memcpy(nextkey, line, cpp);
   2.402  			if(indexed) {
   2.403  				SDL_Color *c = im_colors + index;
   2.404  				c->r = rgb >> 16;
   2.405  				c->g = rgb >> 8;
   2.406  				c->b = rgb;
   2.407 -				add_colorhash(colors, nextkey, cpp, index);
   2.408 +				pixel = index;
   2.409  			} else
   2.410 -				add_colorhash(colors, nextkey, cpp, rgb);
   2.411 +				pixel = rgb;
   2.412 +			add_colorhash(colors, nextkey, cpp, pixel);
   2.413  			nextkey += cpp;
   2.414  			if(rgb == 0xffffffff)
   2.415 -				SDL_SetColorKey(image, SDL_SRCCOLORKEY,
   2.416 -						indexed ? index : rgb);
   2.417 +				SDL_SetColorKey(image, SDL_SRCCOLORKEY, pixel);
   2.418  			break;
   2.419  		}
   2.420  	}
   2.421  
   2.422  	/* Read the pixels */
   2.423  	pixels_len = w * cpp;
   2.424 -	pixels = malloc(MAX(pixels_len + 5, 20));
   2.425 -	if(!pixels) {
   2.426 -		error = "Out of memory";
   2.427 -		goto done;
   2.428 -	}
   2.429  	dst = image->pixels;
   2.430 -	for (y = 0; y < h; ) {
   2.431 -		char *s;
   2.432 -		char c;
   2.433 -		do {
   2.434 -			if(SDL_RWread(src, &c, 1, 1) <= 0) {
   2.435 -				error = "Premature end of data";
   2.436 -				goto done;
   2.437 -			}
   2.438 -		} while(c == ' ');
   2.439 -		if(c != '"') {
   2.440 -			/* comment or empty line, skip it */
   2.441 -			while(c != '\n' && c != '\r') {
   2.442 -				if(SDL_RWread(src, &c, 1, 1) <= 0) {
   2.443 -					error = "Premature end of data";
   2.444 -					goto done;
   2.445 -				}
   2.446 -			}
   2.447 -			continue;
   2.448 -		}
   2.449 -		if(SDL_RWread(src, pixels, pixels_len + 3, 1) <= 0) {
   2.450 -			error = "Premature end of data";
   2.451 -			goto done;
   2.452 -		}
   2.453 -		s = pixels;
   2.454 +	for(y = 0; y < h; y++) {
   2.455 +		line = get_next_line(xpmlines, src, pixels_len);
   2.456  		if(indexed) {
   2.457  			/* optimization for some common cases */
   2.458  			if(cpp == 1)
   2.459  				for(x = 0; x < w; x++)
   2.460  					dst[x] = QUICK_COLORHASH(colors,
   2.461 -								 s + x);
   2.462 +								 line + x);
   2.463  			else
   2.464  				for(x = 0; x < w; x++)
   2.465  					dst[x] = get_colorhash(colors,
   2.466 -							       s + x * cpp,
   2.467 +							       line + x * cpp,
   2.468  							       cpp);
   2.469  		} else {
   2.470  			for (x = 0; x < w; x++)
   2.471  				((Uint32*)dst)[x] = get_colorhash(colors,
   2.472 -								  s + x * cpp,
   2.473 +								line + x * cpp,
   2.474  								  cpp);
   2.475  		}
   2.476  		dst += image->pitch;
   2.477 -		y++;
   2.478  	}
   2.479  
   2.480  done:
   2.481  	if(error) {
   2.482 -		if(image)
   2.483 -			SDL_FreeSurface(image);
   2.484 +		SDL_FreeSurface(image);
   2.485  		image = NULL;
   2.486  		IMG_SetError(error);
   2.487  	}
   2.488 -	free(pixels);
   2.489  	free(keystrings);
   2.490  	free_colorhash(colors);
   2.491 +	free(linebuf);
   2.492  	return(image);
   2.493  }
   2.494  
   2.495 -#else
   2.496 +/* Load a XPM type image from an RWops datasource */
   2.497 +SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src)
   2.498 +{
   2.499 +	return load_xpm(NULL, src);
   2.500 +}
   2.501 +
   2.502 +SDL_Surface *IMG_ReadXPMFromArray(char **xpm)
   2.503 +{
   2.504 +	return load_xpm(xpm, NULL);
   2.505 +}
   2.506 +
   2.507 +#else  /* not LOAD_XPM */
   2.508  
   2.509  /* See if an image is contained in a data source */
   2.510  int IMG_isXPM(SDL_RWops *src)
   2.511 @@ -453,10 +468,15 @@
   2.512  	return(0);
   2.513  }
   2.514  
   2.515 +
   2.516  /* Load a XPM type image from an SDL datasource */
   2.517  SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src)
   2.518  {
   2.519  	return(NULL);
   2.520  }
   2.521  
   2.522 -#endif /* LOAD_XPM */
   2.523 +SDL_Surface *IMG_ReadXPMFromArray(char **xpm)
   2.524 +{
   2.525 +    return NULL;
   2.526 +}
   2.527 +#endif /* not LOAD_XPM */
     3.1 --- a/README	Fri Apr 06 03:27:14 2001 +0000
     3.2 +++ b/README	Sat Apr 28 18:24:37 2001 +0000
     3.3 @@ -20,6 +20,10 @@
     3.4  where type is a string specifying the format (i.e. "PNG" or "pcx").
     3.5  Note that IMG_Load_RW cannot load TGA images.
     3.6  
     3.7 +To create a surface from an XPM image included in C source, use:
     3.8 +
     3.9 +	SDL_Surface *IMG_ReadXPMFromArray(char **xpm);
    3.10 +
    3.11  An example program 'showimage' is included, with source in showimage.c
    3.12  
    3.13  JPEG support requires the JPEG library: http://www.ijg.org/
     4.1 --- a/SDL_image.h	Fri Apr 06 03:27:14 2001 +0000
     4.2 +++ b/SDL_image.h	Sat Apr 28 18:24:37 2001 +0000
     4.3 @@ -77,13 +77,12 @@
     4.4  extern DECLSPEC SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src);
     4.5  extern DECLSPEC SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src);
     4.6  
     4.7 +extern DECLSPEC SDL_Surface *IMG_ReadXPMFromArray(char **xpm);
     4.8 +
     4.9  /* We'll use SDL for reporting errors */
    4.10  #define IMG_SetError	SDL_SetError
    4.11  #define IMG_GetError	SDL_GetError
    4.12  
    4.13 -/* used internally, NOT an exported function */
    4.14 -extern DECLSPEC int IMG_string_equals(const char *str1, const char *str2);
    4.15 -
    4.16  /* Ends C function definitions when using C++ */
    4.17  #ifdef __cplusplus
    4.18  }
     5.1 --- a/configure.in	Fri Apr 06 03:27:14 2001 +0000
     5.2 +++ b/configure.in	Sat Apr 28 18:24:37 2001 +0000
     5.3 @@ -13,9 +13,9 @@
     5.4  
     5.5  MAJOR_VERSION=1
     5.6  MINOR_VERSION=2
     5.7 -MICRO_VERSION=0
     5.8 +MICRO_VERSION=1
     5.9  INTERFACE_AGE=0
    5.10 -BINARY_AGE=0
    5.11 +BINARY_AGE=1
    5.12  VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
    5.13  
    5.14  AC_SUBST(MAJOR_VERSION)
     6.1 --- a/showimage.c	Fri Apr 06 03:27:14 2001 +0000
     6.2 +++ b/showimage.c	Sat Apr 28 18:24:37 2001 +0000
     6.3 @@ -29,6 +29,12 @@
     6.4  #include "SDL.h"
     6.5  #include "SDL_image.h"
     6.6  
     6.7 +/* #define XPM_INCLUDED and supply picture.xpm to test the XPM inclusion
     6.8 +   feature */
     6.9 +
    6.10 +#ifdef XPM_INCLUDED
    6.11 +#include "picture.xpm"
    6.12 +#endif
    6.13  
    6.14  /* Draw a Gimpish background pattern to show transparency in the image */
    6.15  void draw_background(SDL_Surface *screen)
    6.16 @@ -97,7 +103,11 @@
    6.17  			continue;
    6.18  		}
    6.19  		/* Open the image file */
    6.20 +#ifdef XPM_INCLUDED
    6.21 +		image = IMG_ReadXPMFromArray(picture_xpm);
    6.22 +#else
    6.23  		image = IMG_Load(argv[i]);
    6.24 +#endif
    6.25  		if ( image == NULL ) {
    6.26  			fprintf(stderr, "Couldn't load %s: %s\n",
    6.27  			        argv[i], SDL_GetError());