In the process of tracking down bug #868, made ImageIO the default for building using command line tools, and cleaned up the ImageIO image loading code.
authorSam Lantinga <slouken@libsdl.org>
Tue, 10 Nov 2009 06:00:59 +0000
changeset 237d1a4fae44bd0
parent 236 cce1251de477
child 238 ffe1f112ca0c
In the process of tracking down bug #868, made ImageIO the default for building using command line tools, and cleaned up the ImageIO image loading code.
IMG_ImageIO.c
IMG_UIImage.m
IMG_bmp.c
IMG_gif.c
IMG_jpg.c
IMG_png.c
IMG_tga.c
IMG_tif.c
Makefile.am
configure.in
     1.1 --- a/IMG_ImageIO.c	Sun Nov 08 17:13:36 2009 +0000
     1.2 +++ b/IMG_ImageIO.c	Tue Nov 10 06:00:59 2009 +0000
     1.3 @@ -226,18 +226,13 @@
     1.4  	 * non-RGBA image formats so I'm making the rest up.
     1.5  	 * All this code should be scrutinized.
     1.6  	 */
     1.7 -	
     1.8 +
     1.9  	size_t the_width = CGImageGetWidth(image_ref);
    1.10  	size_t the_height = CGImageGetHeight(image_ref);
    1.11  	CGRect the_rect = {{0, 0}, {the_width, the_height}};
    1.12 -	
    1.13 +
    1.14  	size_t bits_per_pixel = CGImageGetBitsPerPixel(image_ref);
    1.15 -	size_t bytes_per_row = CGImageGetBytesPerRow(image_ref);
    1.16 -	//	size_t bits_per_component = CGImageGetBitsPerComponent(image_ref);
    1.17  	size_t bits_per_component = 8;
    1.18 -	
    1.19 -//	CGImageAlphaInfo alpha_info = CGImageGetAlphaInfo(image_ref);
    1.20 -	
    1.21  
    1.22  	SDL_Surface* sdl_surface = NULL;
    1.23  	Uint32 Rmask;
    1.24 @@ -245,144 +240,73 @@
    1.25  	Uint32 Bmask;
    1.26  	Uint32 Amask;
    1.27  
    1.28 -	
    1.29  	CGContextRef bitmap_context = NULL;
    1.30 -	
    1.31  	CGColorSpaceRef color_space = NULL;
    1.32  	CGBitmapInfo bitmap_info = CGImageGetBitmapInfo(image_ref);
    1.33  
    1.34 -	
    1.35 -	switch(bits_per_pixel)
    1.36 +	switch (bits_per_pixel)
    1.37  	{
    1.38 -		case 8:
    1.39 +		case 32:
    1.40  		{
    1.41 -			bytes_per_row = the_width*4;
    1.42 -			//				color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
    1.43  			color_space = CGColorSpaceCreateDeviceRGB();
    1.44 -			//				bitmap_info = kCGImageAlphaPremultipliedFirst;
    1.45 +#if __BIG_ENDIAN__
    1.46 +			//bitmap_info = kCGImageAlphaFirst | kCGBitmapByteOrder32Big; /* ARGB Big Endian */
    1.47 +			bitmap_info = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Big; /* ARGB Big Endian */
    1.48 +#else
    1.49 +			//bitmap_info = kCGImageAlphaFirst | kCGBitmapByteOrder32Little; /* ARGB Little Endian */
    1.50 +			bitmap_info = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little; /* ARGB Little Endian */
    1.51 +#endif 
    1.52 +			Amask = 0xFF000000;
    1.53 +			Rmask = 0x00FF0000;
    1.54 +			Gmask = 0x0000FF00;
    1.55 +			Bmask = 0x000000FF;
    1.56 +
    1.57 +			sdl_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, the_width, the_height, 32, Rmask, Gmask, Bmask, Amask);
    1.58 +			break;
    1.59 +		}
    1.60 +		default:
    1.61 +		{
    1.62 +			color_space = CGColorSpaceCreateDeviceRGB();
    1.63  #if __BIG_ENDIAN__
    1.64  			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Big; /* XRGB Big Endian */
    1.65  #else
    1.66  			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little; /* XRGB Little Endian */
    1.67  #endif
    1.68 -
    1.69 -			Rmask = 0x00FF0000;
    1.70 -			Gmask = 0x0000FF00;
    1.71 -			Bmask = 0x000000FF;
    1.72  			Amask = 0x00000000;
    1.73 -
    1.74 -			sdl_surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
    1.75 -											   the_width, the_height, 32, Rmask, Gmask, Bmask, Amask);
    1.76 -
    1.77 -
    1.78 -			
    1.79 -			break;
    1.80 -		}
    1.81 -		case 15:
    1.82 -		case 16:
    1.83 -		{
    1.84 -			bytes_per_row = the_width*4;
    1.85 -
    1.86 -			color_space = CGColorSpaceCreateDeviceRGB();
    1.87 -
    1.88 -#if __BIG_ENDIAN__
    1.89 -			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Big; /* XRGB Big Endian */
    1.90 -#else
    1.91 -			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little; /* XRGB Little Endian */
    1.92 -#endif
    1.93 -			Rmask = 0x00FF0000;
    1.94 -			Gmask = 0x0000FF00;
    1.95 -			Bmask = 0x000000FF;
    1.96 -			Amask = 0x00000000;
    1.97 -
    1.98 -
    1.99 -			sdl_surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
   1.100 -											   the_width, the_height, 32, Rmask, Gmask, Bmask, Amask);
   1.101 -
   1.102 -			break;
   1.103 -		}
   1.104 -		case 24:
   1.105 -		{
   1.106 -			bytes_per_row = the_width*4;
   1.107 -			//			color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
   1.108 -			color_space = CGColorSpaceCreateDeviceRGB();
   1.109 -			//			bitmap_info = kCGImageAlphaNone;
   1.110 -#if __BIG_ENDIAN__
   1.111 -			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Big; /* XRGB Big Endian */
   1.112 -#else
   1.113 -			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little; /* XRGB Little Endian */
   1.114 -#endif
   1.115 -			Rmask = 0x00FF0000;
   1.116 -			Gmask = 0x0000FF00;
   1.117 -			Bmask = 0x000000FF;
   1.118 -			Amask = 0x00000000;
   1.119 -
   1.120 -			sdl_surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
   1.121 -											   the_width, the_height, 32, Rmask, Gmask, Bmask, Amask);
   1.122 -
   1.123 -			break;
   1.124 -		}
   1.125 -		case 32:
   1.126 -		{
   1.127 -						
   1.128 -			bytes_per_row = the_width*4;
   1.129 -			//			color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
   1.130 -			color_space = CGColorSpaceCreateDeviceRGB();
   1.131 -			//			bitmap_info = kCGImageAlphaPremultipliedFirst;
   1.132 -#if __BIG_ENDIAN__
   1.133 -			bitmap_info = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Big; /* XRGB Big Endian */
   1.134 -#else
   1.135 -			bitmap_info = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little; /* XRGB Little Endian */
   1.136 -#endif 
   1.137 -
   1.138 -			Amask = 0xFF000000;
   1.139  			Rmask = 0x00FF0000;
   1.140  			Gmask = 0x0000FF00;
   1.141  			Bmask = 0x000000FF;
   1.142  
   1.143 -			sdl_surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
   1.144 -											   the_width, the_height, 32, Rmask, Gmask, Bmask, Amask);
   1.145 +			sdl_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, the_width, the_height, 32, Rmask, Gmask, Bmask, Amask);
   1.146  			break;
   1.147  		}
   1.148 -		default:
   1.149 -		{
   1.150 -            sdl_surface = NULL;
   1.151 -            break;
   1.152 -		}
   1.153 -			
   1.154  	}
   1.155  
   1.156 -	if(NULL == sdl_surface)
   1.157 +	if (sdl_surface)
   1.158  	{
   1.159 -		if(color_space != NULL)
   1.160 -		{
   1.161 -			CGColorSpaceRelease(color_space);			
   1.162 -		}
   1.163 -		return NULL;
   1.164 +		// Sets up a context to be drawn to with sdl_surface->pixels as the area to be drawn to
   1.165 +		bitmap_context = CGBitmapContextCreate(
   1.166 +															sdl_surface->pixels,
   1.167 +															the_width,
   1.168 +															the_height,
   1.169 +															bits_per_component,
   1.170 +															sdl_surface->pitch,
   1.171 +															color_space,
   1.172 +															bitmap_info
   1.173 +															);
   1.174 +
   1.175 +		// Draws the image into the context's image_data
   1.176 +		CGContextDrawImage(bitmap_context, the_rect, image_ref);
   1.177 +
   1.178 +		CGContextRelease(bitmap_context);
   1.179  	}
   1.180  
   1.181 +	if (color_space)
   1.182 +	{
   1.183 +		CGColorSpaceRelease(color_space);			
   1.184 +	}
   1.185  
   1.186 -	// Sets up a context to be drawn to with sdl_surface->pixels as the area to be drawn to
   1.187 -	bitmap_context = CGBitmapContextCreate(
   1.188 -														sdl_surface->pixels,
   1.189 -														the_width,
   1.190 -														the_height,
   1.191 -														bits_per_component,
   1.192 -														bytes_per_row,
   1.193 -														color_space,
   1.194 -														bitmap_info
   1.195 -														);
   1.196 -	
   1.197 -	// Draws the image into the context's image_data
   1.198 -	CGContextDrawImage(bitmap_context, the_rect, image_ref);
   1.199 -	
   1.200 -	CGContextRelease(bitmap_context);
   1.201 -	CGColorSpaceRelease(color_space);
   1.202 -	
   1.203  	return sdl_surface;
   1.204 -	
   1.205 -	
   1.206 -	
   1.207  }
   1.208  
   1.209  
     2.1 --- a/IMG_UIImage.m	Sun Nov 08 17:13:36 2009 +0000
     2.2 +++ b/IMG_UIImage.m	Tue Nov 10 06:00:59 2009 +0000
     2.3 @@ -21,18 +21,13 @@
     2.4  	 * non-RGBA image formats so I'm making the rest up.
     2.5  	 * All this code should be scrutinized.
     2.6  	 */
     2.7 -	
     2.8 +
     2.9  	size_t the_width = CGImageGetWidth(image_ref);
    2.10  	size_t the_height = CGImageGetHeight(image_ref);
    2.11  	CGRect the_rect = {{0, 0}, {the_width, the_height}};
    2.12 -	
    2.13 +
    2.14  	size_t bits_per_pixel = CGImageGetBitsPerPixel(image_ref);
    2.15 -	size_t bytes_per_row = CGImageGetBytesPerRow(image_ref);
    2.16 -	//	size_t bits_per_component = CGImageGetBitsPerComponent(image_ref);
    2.17  	size_t bits_per_component = 8;
    2.18 -	
    2.19 -//	CGImageAlphaInfo alpha_info = CGImageGetAlphaInfo(image_ref);
    2.20 -	
    2.21  
    2.22  	SDL_Surface* sdl_surface = NULL;
    2.23  	Uint32 Rmask;
    2.24 @@ -40,143 +35,73 @@
    2.25  	Uint32 Bmask;
    2.26  	Uint32 Amask;
    2.27  
    2.28 -	
    2.29  	CGContextRef bitmap_context = NULL;
    2.30 -	
    2.31  	CGColorSpaceRef color_space = NULL;
    2.32  	CGBitmapInfo bitmap_info = CGImageGetBitmapInfo(image_ref);
    2.33  
    2.34 -	
    2.35 -	switch(bits_per_pixel)
    2.36 +	switch (bits_per_pixel)
    2.37  	{
    2.38 -		case 8:
    2.39 -		{
    2.40 -			bytes_per_row = the_width*4;
    2.41 -			//				color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
    2.42 -			color_space = CGColorSpaceCreateDeviceRGB();
    2.43 -			//				bitmap_info = kCGImageAlphaPremultipliedFirst;
    2.44 -#if __BIG_ENDIAN__
    2.45 -			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Big; /* XRGB Big Endian */
    2.46 -#else
    2.47 -			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little; /* XRGB Little Endian */
    2.48 -#endif
    2.49 -
    2.50 -			Rmask = 0x00FF0000;
    2.51 -			Gmask = 0x0000FF00;
    2.52 -			Bmask = 0x000000FF;
    2.53 -			Amask = 0x00000000;
    2.54 -
    2.55 -			sdl_surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
    2.56 -											   the_width, the_height, 32, Rmask, Gmask, Bmask, Amask);
    2.57 -
    2.58 -
    2.59 -			
    2.60 -			break;
    2.61 -		}
    2.62 -		case 15:
    2.63 -		case 16:
    2.64 -		{
    2.65 -			bytes_per_row = the_width*4;
    2.66 -
    2.67 -			color_space = CGColorSpaceCreateDeviceRGB();
    2.68 -
    2.69 -#if __BIG_ENDIAN__
    2.70 -			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Big; /* XRGB Big Endian */
    2.71 -#else
    2.72 -			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little; /* XRGB Little Endian */
    2.73 -#endif
    2.74 -			Rmask = 0x00FF0000;
    2.75 -			Gmask = 0x0000FF00;
    2.76 -			Bmask = 0x000000FF;
    2.77 -			Amask = 0x00000000;
    2.78 -
    2.79 -
    2.80 -			sdl_surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
    2.81 -											   the_width, the_height, 32, Rmask, Gmask, Bmask, Amask);
    2.82 -
    2.83 -			break;
    2.84 -		}
    2.85 -		case 24:
    2.86 -		{
    2.87 -			bytes_per_row = the_width*4;
    2.88 -			//			color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
    2.89 -			color_space = CGColorSpaceCreateDeviceRGB();
    2.90 -			//			bitmap_info = kCGImageAlphaNone;
    2.91 -#if __BIG_ENDIAN__
    2.92 -			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Big; /* XRGB Big Endian */
    2.93 -#else
    2.94 -			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little; /* XRGB Little Endian */
    2.95 -#endif
    2.96 -			Rmask = 0x00FF0000;
    2.97 -			Gmask = 0x0000FF00;
    2.98 -			Bmask = 0x000000FF;
    2.99 -			Amask = 0x00000000;
   2.100 -
   2.101 -			sdl_surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
   2.102 -											   the_width, the_height, 32, Rmask, Gmask, Bmask, Amask);
   2.103 -
   2.104 -			break;
   2.105 -		}
   2.106  		case 32:
   2.107  		{
   2.108 -						
   2.109 -			bytes_per_row = the_width*4;
   2.110 -			//			color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
   2.111  			color_space = CGColorSpaceCreateDeviceRGB();
   2.112 -			//			bitmap_info = kCGImageAlphaPremultipliedFirst;
   2.113  #if __BIG_ENDIAN__
   2.114 -			bitmap_info = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Big; /* XRGB Big Endian */
   2.115 +			//bitmap_info = kCGImageAlphaFirst | kCGBitmapByteOrder32Big; /* ARGB Big Endian */
   2.116 +			bitmap_info = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Big; /* ARGB Big Endian */
   2.117  #else
   2.118 -			bitmap_info = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little; /* XRGB Little Endian */
   2.119 +			//bitmap_info = kCGImageAlphaFirst | kCGBitmapByteOrder32Little; /* ARGB Little Endian */
   2.120 +			bitmap_info = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little; /* ARGB Little Endian */
   2.121  #endif 
   2.122  			Amask = 0xFF000000;
   2.123  			Rmask = 0x00FF0000;
   2.124  			Gmask = 0x0000FF00;
   2.125  			Bmask = 0x000000FF;
   2.126  
   2.127 -			sdl_surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
   2.128 -											   the_width, the_height, 32, Rmask, Gmask, Bmask, Amask);
   2.129 +			sdl_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, the_width, the_height, 32, Rmask, Gmask, Bmask, Amask);
   2.130  			break;
   2.131  		}
   2.132  		default:
   2.133  		{
   2.134 -            sdl_surface = NULL;
   2.135 -            break;
   2.136 +			color_space = CGColorSpaceCreateDeviceRGB();
   2.137 +#if __BIG_ENDIAN__
   2.138 +			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Big; /* XRGB Big Endian */
   2.139 +#else
   2.140 +			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little; /* XRGB Little Endian */
   2.141 +#endif
   2.142 +			Amask = 0x00000000;
   2.143 +			Rmask = 0x00FF0000;
   2.144 +			Gmask = 0x0000FF00;
   2.145 +			Bmask = 0x000000FF;
   2.146 +
   2.147 +			sdl_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, the_width, the_height, 32, Rmask, Gmask, Bmask, Amask);
   2.148 +			break;
   2.149  		}
   2.150 -			
   2.151  	}
   2.152  
   2.153 -	if(NULL == sdl_surface)
   2.154 +	if (sdl_surface)
   2.155  	{
   2.156 -		if(color_space != NULL)
   2.157 -		{
   2.158 -			CGColorSpaceRelease(color_space);			
   2.159 -		}
   2.160 -		return NULL;
   2.161 +		// Sets up a context to be drawn to with sdl_surface->pixels as the area to be drawn to
   2.162 +		bitmap_context = CGBitmapContextCreate(
   2.163 +															sdl_surface->pixels,
   2.164 +															the_width,
   2.165 +															the_height,
   2.166 +															bits_per_component,
   2.167 +															sdl_surface->pitch,
   2.168 +															color_space,
   2.169 +															bitmap_info
   2.170 +															);
   2.171 +
   2.172 +		// Draws the image into the context's image_data
   2.173 +		CGContextDrawImage(bitmap_context, the_rect, image_ref);
   2.174 +
   2.175 +		CGContextRelease(bitmap_context);
   2.176  	}
   2.177  
   2.178 +	if (color_space)
   2.179 +	{
   2.180 +		CGColorSpaceRelease(color_space);			
   2.181 +	}
   2.182  
   2.183 -	// Sets up a context to be drawn to with sdl_surface->pixels as the area to be drawn to
   2.184 -	bitmap_context = CGBitmapContextCreate(
   2.185 -														sdl_surface->pixels,
   2.186 -														the_width,
   2.187 -														the_height,
   2.188 -														bits_per_component,
   2.189 -														bytes_per_row,
   2.190 -														color_space,
   2.191 -														bitmap_info
   2.192 -														);
   2.193 -	
   2.194 -	// Draws the image into the context's image_data
   2.195 -	CGContextDrawImage(bitmap_context, the_rect, image_ref);
   2.196 -	
   2.197 -	CGContextRelease(bitmap_context);
   2.198 -	CGColorSpaceRelease(color_space);
   2.199 -	
   2.200  	return sdl_surface;
   2.201 -	
   2.202 -	
   2.203 -	
   2.204  }
   2.205  
   2.206  static SDL_Surface* LoadImageFromRWops(SDL_RWops* rw_ops, CFStringRef uti_string_hint)
     3.1 --- a/IMG_bmp.c	Sun Nov 08 17:13:36 2009 +0000
     3.2 +++ b/IMG_bmp.c	Tue Nov 10 06:00:59 2009 +0000
     3.3 @@ -20,6 +20,8 @@
     3.4      slouken@libsdl.org
     3.5  */
     3.6  
     3.7 +#if !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND)
     3.8 +
     3.9  /* This is a BMP image file loading framework */
    3.10  /* ICO/CUR file support is here as well since it uses similar internal
    3.11   * representation */
    3.12 @@ -839,3 +841,5 @@
    3.13  }
    3.14  
    3.15  #endif /* LOAD_BMP */
    3.16 +
    3.17 +#endif /* !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND) */
     4.1 --- a/IMG_gif.c	Sun Nov 08 17:13:36 2009 +0000
     4.2 +++ b/IMG_gif.c	Tue Nov 10 06:00:59 2009 +0000
     4.3 @@ -20,6 +20,8 @@
     4.4      slouken@libsdl.org
     4.5  */
     4.6  
     4.7 +#if !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND)
     4.8 +
     4.9  /* This is a GIF image file loading framework */
    4.10  
    4.11  #include <stdio.h>
    4.12 @@ -620,3 +622,5 @@
    4.13  }
    4.14  
    4.15  #endif /* LOAD_GIF */
    4.16 +
    4.17 +#endif /* !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND) */
     5.1 --- a/IMG_jpg.c	Sun Nov 08 17:13:36 2009 +0000
     5.2 +++ b/IMG_jpg.c	Tue Nov 10 06:00:59 2009 +0000
     5.3 @@ -20,6 +20,8 @@
     5.4      slouken@libsdl.org
     5.5  */
     5.6  
     5.7 +#if !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND)
     5.8 +
     5.9  /* This is a JPEG image file loading framework */
    5.10  
    5.11  #include <stdio.h>
    5.12 @@ -484,3 +486,5 @@
    5.13  }
    5.14  
    5.15  #endif /* LOAD_JPG */
    5.16 +
    5.17 +#endif /* !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND) */
     6.1 --- a/IMG_png.c	Sun Nov 08 17:13:36 2009 +0000
     6.2 +++ b/IMG_png.c	Tue Nov 10 06:00:59 2009 +0000
     6.3 @@ -20,6 +20,8 @@
     6.4      slouken@libsdl.org
     6.5  */
     6.6  
     6.7 +#if !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND)
     6.8 +
     6.9  /* This is a PNG image file loading framework */
    6.10  
    6.11  #include <stdlib.h>
    6.12 @@ -527,3 +529,5 @@
    6.13  }
    6.14  
    6.15  #endif /* LOAD_PNG */
    6.16 +
    6.17 +#endif /* !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND) */
     7.1 --- a/IMG_tga.c	Sun Nov 08 17:13:36 2009 +0000
     7.2 +++ b/IMG_tga.c	Tue Nov 10 06:00:59 2009 +0000
     7.3 @@ -20,6 +20,10 @@
     7.4      slouken@libsdl.org
     7.5  */
     7.6  
     7.7 +#if !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND)
     7.8 +
     7.9 +/* This is a Targa image file loading framework */
    7.10 +
    7.11  #include <stdlib.h>
    7.12  #include <stdio.h>
    7.13  #include <string.h>
    7.14 @@ -329,3 +333,5 @@
    7.15  }
    7.16  
    7.17  #endif /* LOAD_TGA */
    7.18 +
    7.19 +#endif /* !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND) */
     8.1 --- a/IMG_tif.c	Sun Nov 08 17:13:36 2009 +0000
     8.2 +++ b/IMG_tif.c	Tue Nov 10 06:00:59 2009 +0000
     8.3 @@ -20,6 +20,8 @@
     8.4      slouken@libsdl.org
     8.5  */
     8.6  
     8.7 +#if !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND)
     8.8 +
     8.9  /* This is a TIFF image file loading framework */
    8.10  
    8.11  #include <stdio.h>
    8.12 @@ -293,3 +295,5 @@
    8.13  }
    8.14  
    8.15  #endif /* LOAD_TIF */
    8.16 +
    8.17 +#endif /* !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND) */
     9.1 --- a/Makefile.am	Sun Nov 08 17:13:36 2009 +0000
     9.2 +++ b/Makefile.am	Tue Nov 10 06:00:59 2009 +0000
     9.3 @@ -19,7 +19,8 @@
     9.4  	IMG_tif.c		\
     9.5  	IMG_xcf.c		\
     9.6  	IMG_xpm.c		\
     9.7 -	IMG_xv.c
     9.8 +	IMG_xv.c		\
     9.9 +	IMG_ImageIO.c
    9.10  
    9.11  EXTRA_DIST =			\
    9.12  	CHANGES			\
    9.13 @@ -31,7 +32,6 @@
    9.14  	MPWmake.sea.bin		\
    9.15  	Watcom-OS2.zip		\
    9.16  	IMG_xxx.c		\
    9.17 -	IMG_ImageIO.c		\
    9.18  	IMG_UIImage.m		\
    9.19  	SDL_image.spec		\
    9.20  	gcc-fat.sh		\
    10.1 --- a/configure.in	Sun Nov 08 17:13:36 2009 +0000
    10.2 +++ b/configure.in	Tue Nov 10 06:00:59 2009 +0000
    10.3 @@ -75,6 +75,15 @@
    10.4              use_version_rc=true
    10.5          fi
    10.6          ;;
    10.7 +    *-*-darwin*)
    10.8 +        AC_ARG_ENABLE([imageio], [AC_HELP_STRING([--enable-imageio], [use native Mac OS X frameworks for loading images [default=yes]])],
    10.9 +                      [], [enable_imageio=yes])
   10.10 +        if test x$enable_imageio = xyes; then
   10.11 +            IMG_LIBS="-Wl,-framework,ApplicationServices $IMG_LIBS"
   10.12 +        else
   10.13 +            CFLAGS="$CFLAGS -DSDL_IMAGE_USE_COMMON_BACKEND"
   10.14 +        fi
   10.15 +        ;;
   10.16  esac
   10.17  AM_CONDITIONAL(USE_VERSION_RC, test x$use_version_rc = xtrue)
   10.18  
   10.19 @@ -108,7 +117,7 @@
   10.20              :,
   10.21             AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
   10.22  )
   10.23 -CFLAGS="$CFLAGS -DSDL_IMAGE_USE_COMMON_BACKEND $SDL_CFLAGS"
   10.24 +CFLAGS="$CFLAGS $SDL_CFLAGS"
   10.25  LIBS="$LIBS $SDL_LIBS"
   10.26  saved_LIBS="$LIBS"
   10.27