IMG_UIImage.m
author Sam Lantinga <slouken@libsdl.org>
Thu, 08 Oct 2009 05:35:16 +0000
changeset 219 de70ba5fc166
parent 195 6df7a974044f
child 233 fd5471011130
permissions -rw-r--r--
Eric Wing to Sam

I think the main problem the person was having was the default was set to use the 2.2 SDK, but it no longer is installed by default. I think this is going to be a recurring problem as time moves on. I bumped the SDK to the latest for now.

I also renamed the build configuration names to UIImage instead of IOImage which made things confusing. I also gutted a bunch of things including old references to our PowerPC/Intel stuff from the Mac, references to libpng/libjpeg, and deleted the old binaries to them since they were not ARM.

Also deleted SDLMain from the showimage since I presume iPhone requires SDL 1.3. That brings up a point that all the Mac test programs will have a problem with SDLmain since the checkout is the same for both 1.2 and 1.3.

Also, there is a #import change in IMG_UIImage.m.
slouken@187
     1
/*
slouken@187
     2
 *  IMG_ImageIO.c
slouken@187
     3
 *  SDL_image
slouken@187
     4
 *
slouken@187
     5
 *  Created by Eric Wing on 1/2/09.
slouken@187
     6
 *  Copyright 2009 __MyCompanyName__. All rights reserved.
slouken@187
     7
 *
slouken@187
     8
 */
slouken@187
     9
#include "SDL_image.h"
slouken@187
    10
#import <UIKit/UIKit.h>
slouken@219
    11
#import <MobileCoreServices/MobileCoreServices.h> // for UTCoreTypes.h
slouken@187
    12
slouken@187
    13
// Once we have our image, we need to get it into an SDL_Surface
slouken@187
    14
// (Copied straight from the ImageIO backend.)
slouken@187
    15
static SDL_Surface* Create_SDL_Surface_From_CGImage(CGImageRef image_ref)
slouken@187
    16
{
slouken@187
    17
	/* This code is adapted from Apple's Documentation found here:
slouken@187
    18
	 * http://developer.apple.com/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/index.html
slouken@187
    19
	 * Listing 9-4††Using a Quartz image as a texture source.
slouken@187
    20
	 * Unfortunately, this guide doesn't show what to do about
slouken@187
    21
	 * non-RGBA image formats so I'm making the rest up.
slouken@187
    22
	 * All this code should be scrutinized.
slouken@187
    23
	 */
slouken@187
    24
	
slouken@187
    25
	size_t the_width = CGImageGetWidth(image_ref);
slouken@187
    26
	size_t the_height = CGImageGetHeight(image_ref);
slouken@187
    27
	CGRect the_rect = {{0, 0}, {the_width, the_height}};
slouken@187
    28
	
slouken@187
    29
	size_t bits_per_pixel = CGImageGetBitsPerPixel(image_ref);
slouken@187
    30
	size_t bytes_per_row = CGImageGetBytesPerRow(image_ref);
slouken@187
    31
	//	size_t bits_per_component = CGImageGetBitsPerComponent(image_ref);
slouken@187
    32
	size_t bits_per_component = 8;
slouken@187
    33
	
slouken@187
    34
//	CGImageAlphaInfo alpha_info = CGImageGetAlphaInfo(image_ref);
slouken@187
    35
	
slouken@187
    36
slouken@187
    37
	SDL_Surface* sdl_surface = NULL;
slouken@187
    38
	Uint32 Rmask;
slouken@187
    39
	Uint32 Gmask;
slouken@187
    40
	Uint32 Bmask;
slouken@187
    41
	Uint32 Amask;
slouken@187
    42
slouken@187
    43
	
slouken@187
    44
	CGContextRef bitmap_context = NULL;
slouken@187
    45
	
slouken@187
    46
	CGColorSpaceRef color_space = NULL;
slouken@187
    47
	CGBitmapInfo bitmap_info = CGImageGetBitmapInfo(image_ref);
slouken@187
    48
slouken@187
    49
	
slouken@187
    50
	switch(bits_per_pixel)
slouken@187
    51
	{
slouken@187
    52
		case 8:
slouken@187
    53
		{
slouken@187
    54
			bytes_per_row = the_width*4;
slouken@187
    55
			//				color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
slouken@187
    56
			color_space = CGColorSpaceCreateDeviceRGB();
slouken@187
    57
			//				bitmap_info = kCGImageAlphaPremultipliedFirst;
slouken@187
    58
#if __BIG_ENDIAN__
slouken@187
    59
			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Big; /* XRGB Big Endian */
slouken@187
    60
#else
slouken@187
    61
			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little; /* XRGB Little Endian */
slouken@187
    62
#endif
slouken@187
    63
slouken@187
    64
			Rmask = 0x00FF0000;
slouken@187
    65
			Gmask = 0x0000FF00;
slouken@187
    66
			Bmask = 0x000000FF;
slouken@187
    67
			Amask = 0x00000000;
slouken@187
    68
slouken@187
    69
			sdl_surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
slouken@187
    70
											   the_width, the_height, 32, Rmask, Gmask, Bmask, Amask);
slouken@187
    71
slouken@187
    72
slouken@187
    73
			
slouken@187
    74
			break;
slouken@187
    75
		}
slouken@187
    76
		case 15:
slouken@187
    77
		case 16:
slouken@187
    78
		{
slouken@187
    79
			bytes_per_row = the_width*4;
slouken@187
    80
slouken@187
    81
			color_space = CGColorSpaceCreateDeviceRGB();
slouken@187
    82
slouken@187
    83
#if __BIG_ENDIAN__
slouken@187
    84
			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Big; /* XRGB Big Endian */
slouken@187
    85
#else
slouken@187
    86
			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little; /* XRGB Little Endian */
slouken@187
    87
#endif
slouken@187
    88
			Rmask = 0x00FF0000;
slouken@187
    89
			Gmask = 0x0000FF00;
slouken@187
    90
			Bmask = 0x000000FF;
slouken@187
    91
			Amask = 0x00000000;
slouken@187
    92
slouken@187
    93
slouken@187
    94
			sdl_surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
slouken@187
    95
											   the_width, the_height, 32, Rmask, Gmask, Bmask, Amask);
slouken@187
    96
slouken@187
    97
			break;
slouken@187
    98
		}
slouken@187
    99
		case 24:
slouken@187
   100
		{
slouken@187
   101
			bytes_per_row = the_width*4;
slouken@187
   102
			//			color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
slouken@187
   103
			color_space = CGColorSpaceCreateDeviceRGB();
slouken@187
   104
			//			bitmap_info = kCGImageAlphaNone;
slouken@187
   105
#if __BIG_ENDIAN__
slouken@187
   106
			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Big; /* XRGB Big Endian */
slouken@187
   107
#else
slouken@187
   108
			bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little; /* XRGB Little Endian */
slouken@187
   109
#endif
slouken@187
   110
			Rmask = 0x00FF0000;
slouken@187
   111
			Gmask = 0x0000FF00;
slouken@187
   112
			Bmask = 0x000000FF;
slouken@187
   113
			Amask = 0x00000000;
slouken@187
   114
slouken@187
   115
			sdl_surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
slouken@187
   116
											   the_width, the_height, 32, Rmask, Gmask, Bmask, Amask);
slouken@187
   117
slouken@187
   118
			break;
slouken@187
   119
		}
slouken@187
   120
		case 32:
slouken@187
   121
		{
slouken@187
   122
						
slouken@187
   123
			bytes_per_row = the_width*4;
slouken@187
   124
			//			color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
slouken@187
   125
			color_space = CGColorSpaceCreateDeviceRGB();
slouken@187
   126
			//			bitmap_info = kCGImageAlphaPremultipliedFirst;
slouken@187
   127
#if __BIG_ENDIAN__
slouken@187
   128
			bitmap_info = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Big; /* XRGB Big Endian */
slouken@187
   129
#else
slouken@187
   130
			bitmap_info = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little; /* XRGB Little Endian */
slouken@187
   131
#endif 
slouken@187
   132
			Amask = 0xFF000000;
slouken@187
   133
			Rmask = 0x00FF0000;
slouken@187
   134
			Gmask = 0x0000FF00;
slouken@187
   135
			Bmask = 0x000000FF;
slouken@187
   136
slouken@187
   137
			sdl_surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
slouken@187
   138
											   the_width, the_height, 32, Rmask, Gmask, Bmask, Amask);
slouken@187
   139
			break;
slouken@187
   140
		}
slouken@187
   141
		default:
slouken@187
   142
		{
slouken@187
   143
            sdl_surface = NULL;
slouken@187
   144
            break;
slouken@187
   145
		}
slouken@187
   146
			
slouken@187
   147
	}
slouken@187
   148
slouken@187
   149
	if(NULL == sdl_surface)
slouken@187
   150
	{
slouken@187
   151
		if(color_space != NULL)
slouken@187
   152
		{
slouken@187
   153
			CGColorSpaceRelease(color_space);			
slouken@187
   154
		}
slouken@187
   155
		return NULL;
slouken@187
   156
	}
slouken@187
   157
slouken@187
   158
slouken@187
   159
	// Sets up a context to be drawn to with sdl_surface->pixels as the area to be drawn to
slouken@187
   160
	bitmap_context = CGBitmapContextCreate(
slouken@187
   161
														sdl_surface->pixels,
slouken@187
   162
														the_width,
slouken@187
   163
														the_height,
slouken@187
   164
														bits_per_component,
slouken@187
   165
														bytes_per_row,
slouken@187
   166
														color_space,
slouken@187
   167
														bitmap_info
slouken@187
   168
														);
slouken@187
   169
	
slouken@187
   170
	// Draws the image into the context's image_data
slouken@187
   171
	CGContextDrawImage(bitmap_context, the_rect, image_ref);
slouken@187
   172
	
slouken@187
   173
	CGContextRelease(bitmap_context);
slouken@187
   174
	CGColorSpaceRelease(color_space);
slouken@187
   175
	
slouken@187
   176
	return sdl_surface;
slouken@187
   177
	
slouken@187
   178
	
slouken@187
   179
	
slouken@187
   180
}
slouken@187
   181
slouken@187
   182
static SDL_Surface* LoadImageFromRWops(SDL_RWops* rw_ops, CFStringRef uti_string_hint)
slouken@187
   183
{
slouken@187
   184
	NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
slouken@187
   185
	SDL_Surface* sdl_surface;
slouken@187
   186
	UIImage* ui_image;
slouken@187
   187
slouken@187
   188
	CGImageRef image_ref = NULL;
slouken@187
   189
	int bytes_read = 0;
slouken@187
   190
	// I don't know what a good size is. 
slouken@187
   191
	// Max recommended texture size is 1024x1024 on iPhone so maybe base it on that?
slouken@187
   192
	const int block_size = 1024*4;
slouken@187
   193
	char temp_buffer[block_size];
slouken@187
   194
	
slouken@187
   195
	NSMutableData* ns_data = [[NSMutableData alloc] initWithCapacity:1024*1024*4];
slouken@187
   196
slouken@187
   197
	
slouken@187
   198
	do
slouken@187
   199
	{
slouken@187
   200
		bytes_read = SDL_RWread(rw_ops, temp_buffer, 1, block_size);
slouken@187
   201
		[ns_data appendBytes:temp_buffer length:bytes_read];
slouken@187
   202
	} while(bytes_read > 0);
slouken@187
   203
slouken@187
   204
	if(NULL == image_ref)
slouken@187
   205
	{
slouken@187
   206
		return NULL;
slouken@187
   207
	}
slouken@187
   208
slouken@187
   209
	ui_image = [[UIImage alloc] initWithData:ns_data];
slouken@187
   210
	
slouken@187
   211
	sdl_surface = Create_SDL_Surface_From_CGImage([ui_image CGImage]);
slouken@187
   212
slouken@187
   213
	[ui_image release];
slouken@187
   214
	[ns_data release];
slouken@187
   215
slouken@187
   216
	[autorelease_pool drain];
slouken@187
   217
slouken@187
   218
	return sdl_surface;
slouken@187
   219
}
slouken@187
   220
slouken@188
   221
static SDL_Surface* LoadImageFromFile(const char *file)
slouken@187
   222
{
slouken@187
   223
	NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
slouken@187
   224
	SDL_Surface* sdl_surface = NULL;
slouken@187
   225
	UIImage* ui_image;
slouken@187
   226
	NSString* ns_string;
slouken@187
   227
	
slouken@187
   228
	ns_string = [[NSString alloc] initWithUTF8String:file];
slouken@187
   229
	ui_image = [[UIImage alloc] initWithContentsOfFile:ns_string];
slouken@188
   230
	
slouken@187
   231
	sdl_surface = Create_SDL_Surface_From_CGImage([ui_image CGImage]);
slouken@188
   232
	
slouken@187
   233
	[ui_image release];
slouken@187
   234
	[ns_string release];
slouken@187
   235
	
slouken@187
   236
	[autorelease_pool drain];
slouken@188
   237
	
slouken@188
   238
	return sdl_surface;
slouken@188
   239
}
slouken@187
   240
slouken@188
   241
slouken@188
   242
/* Since UIImage doesn't really support streams well, we should optimize for the file case. */
slouken@188
   243
SDL_Surface *IMG_Load(const char *file)
slouken@188
   244
{
slouken@188
   245
	SDL_Surface* sdl_surface = NULL;
slouken@188
   246
slouken@188
   247
	sdl_surface = LoadImageFromFile(file);
slouken@188
   248
	if(NULL == sdl_surface)
slouken@188
   249
	{
slouken@188
   250
		// Either the file doesn't exist or ImageIO doesn't understand the format.
slouken@188
   251
		// For the latter case, fallback to the native SDL_image handlers.
slouken@188
   252
slouken@188
   253
		SDL_RWops *src = SDL_RWFromFile(file, "rb");
slouken@188
   254
		char *ext = strrchr(file, '.');
slouken@188
   255
		if(ext) {
slouken@188
   256
			ext++;
slouken@188
   257
		}
slouken@188
   258
		if(!src) {
slouken@188
   259
			/* The error message has been set in SDL_RWFromFile */
slouken@188
   260
			return NULL;
slouken@188
   261
		}
slouken@188
   262
		sdl_surface = IMG_LoadTyped_RW(src, 1, ext);
slouken@188
   263
	}
slouken@187
   264
	return sdl_surface;
slouken@187
   265
}
slouken@187
   266
slouken@187
   267
slouken@187
   268
slouken@187
   269
/* Copied straight from other files so I don't have to alter them. */
slouken@195
   270
static int IMG_isICOCUR(SDL_RWops *src, int type)
slouken@195
   271
{
slouken@195
   272
	int start;
slouken@195
   273
	int is_ICOCUR;
slouken@195
   274
slouken@195
   275
	/* The Win32 ICO file header (14 bytes) */
slouken@195
   276
    Uint16 bfReserved;
slouken@195
   277
    Uint16 bfType;
slouken@195
   278
    Uint16 bfCount;
slouken@195
   279
slouken@195
   280
	if ( !src )
slouken@195
   281
		return 0;
slouken@195
   282
	start = SDL_RWtell(src);
slouken@195
   283
	is_ICOCUR = 0;
slouken@195
   284
    bfReserved = SDL_ReadLE16(src);
slouken@195
   285
    bfType = SDL_ReadLE16(src);
slouken@195
   286
    bfCount = SDL_ReadLE16(src);
slouken@195
   287
    if ((bfReserved == 0) && (bfType == type) && (bfCount != 0)) 
slouken@195
   288
    	is_ICOCUR = 1;
slouken@195
   289
	SDL_RWseek(src, start, SEEK_SET);
slouken@195
   290
slouken@195
   291
	return (is_ICOCUR);
slouken@195
   292
}
slouken@195
   293
slouken@195
   294
int IMG_isICO(SDL_RWops *src)
slouken@195
   295
{
slouken@195
   296
	return IMG_isICOCUR(src, 1);
slouken@195
   297
}
slouken@195
   298
slouken@195
   299
int IMG_isCUR(SDL_RWops *src)
slouken@195
   300
{
slouken@195
   301
	return IMG_isICOCUR(src, 2);
slouken@195
   302
}
slouken@195
   303
slouken@187
   304
int IMG_isBMP(SDL_RWops *src)
slouken@187
   305
{
slouken@187
   306
	int start;
slouken@187
   307
	int is_BMP;
slouken@187
   308
	char magic[2];
slouken@187
   309
	
slouken@187
   310
	if ( !src )
slouken@187
   311
		return 0;
slouken@187
   312
	start = SDL_RWtell(src);
slouken@187
   313
	is_BMP = 0;
slouken@187
   314
	if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
slouken@187
   315
		if ( strncmp(magic, "BM", 2) == 0 ) {
slouken@187
   316
			is_BMP = 1;
slouken@187
   317
		}
slouken@187
   318
	}
slouken@187
   319
	SDL_RWseek(src, start, SEEK_SET);
slouken@187
   320
	return(is_BMP);
slouken@187
   321
}
slouken@187
   322
slouken@187
   323
int IMG_isGIF(SDL_RWops *src)
slouken@187
   324
{
slouken@187
   325
	int start;
slouken@187
   326
	int is_GIF;
slouken@187
   327
	char magic[6];
slouken@187
   328
	
slouken@187
   329
	if ( !src )
slouken@187
   330
		return 0;
slouken@187
   331
	start = SDL_RWtell(src);
slouken@187
   332
	is_GIF = 0;
slouken@187
   333
	if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
slouken@187
   334
		if ( (strncmp(magic, "GIF", 3) == 0) &&
slouken@187
   335
			((memcmp(magic + 3, "87a", 3) == 0) ||
slouken@187
   336
			 (memcmp(magic + 3, "89a", 3) == 0)) ) {
slouken@187
   337
			is_GIF = 1;
slouken@187
   338
		}
slouken@187
   339
	}
slouken@187
   340
	SDL_RWseek(src, start, SEEK_SET);
slouken@187
   341
	return(is_GIF);
slouken@187
   342
}
slouken@187
   343
slouken@187
   344
int IMG_isJPG(SDL_RWops *src)
slouken@187
   345
{
slouken@187
   346
	int start;
slouken@187
   347
	int is_JPG;
slouken@187
   348
	int in_scan;
slouken@187
   349
	Uint8 magic[4];
slouken@187
   350
	
slouken@187
   351
	/* This detection code is by Steaphan Greene <stea@cs.binghamton.edu> */
slouken@187
   352
	/* Blame me, not Sam, if this doesn't work right. */
slouken@187
   353
	/* And don't forget to report the problem to the the sdl list too! */
slouken@187
   354
	
slouken@187
   355
	if ( !src )
slouken@187
   356
		return 0;
slouken@187
   357
	start = SDL_RWtell(src);
slouken@187
   358
	is_JPG = 0;
slouken@187
   359
	in_scan = 0;
slouken@187
   360
	if ( SDL_RWread(src, magic, 2, 1) ) {
slouken@187
   361
		if ( (magic[0] == 0xFF) && (magic[1] == 0xD8) ) {
slouken@187
   362
			is_JPG = 1;
slouken@187
   363
			while (is_JPG == 1) {
slouken@187
   364
				if(SDL_RWread(src, magic, 1, 2) != 2) {
slouken@187
   365
					is_JPG = 0;
slouken@187
   366
				} else if( (magic[0] != 0xFF) && (in_scan == 0) ) {
slouken@187
   367
					is_JPG = 0;
slouken@187
   368
				} else if( (magic[0] != 0xFF) || (magic[1] == 0xFF) ) {
slouken@187
   369
					/* Extra padding in JPEG (legal) */
slouken@187
   370
					/* or this is data and we are scanning */
slouken@187
   371
					SDL_RWseek(src, -1, SEEK_CUR);
slouken@187
   372
				} else if(magic[1] == 0xD9) {
slouken@187
   373
					/* Got to end of good JPEG */
slouken@187
   374
					break;
slouken@187
   375
				} else if( (in_scan == 1) && (magic[1] == 0x00) ) {
slouken@187
   376
					/* This is an encoded 0xFF within the data */
slouken@187
   377
				} else if( (magic[1] >= 0xD0) && (magic[1] < 0xD9) ) {
slouken@187
   378
					/* These have nothing else */
slouken@187
   379
				} else if(SDL_RWread(src, magic+2, 1, 2) != 2) {
slouken@187
   380
					is_JPG = 0;
slouken@187
   381
				} else {
slouken@187
   382
					/* Yes, it's big-endian */
slouken@187
   383
					Uint32 start;
slouken@187
   384
					Uint32 size;
slouken@187
   385
					Uint32 end;
slouken@187
   386
					start = SDL_RWtell(src);
slouken@187
   387
					size = (magic[2] << 8) + magic[3];
slouken@187
   388
					end = SDL_RWseek(src, size-2, SEEK_CUR);
slouken@187
   389
					if ( end != start + size - 2 ) is_JPG = 0;
slouken@187
   390
					if ( magic[1] == 0xDA ) {
slouken@187
   391
						/* Now comes the actual JPEG meat */
slouken@187
   392
#ifdef	FAST_IS_JPEG
slouken@187
   393
						/* Ok, I'm convinced.  It is a JPEG. */
slouken@187
   394
						break;
slouken@187
   395
#else
slouken@187
   396
						/* I'm not convinced.  Prove it! */
slouken@187
   397
						in_scan = 1;
slouken@187
   398
#endif
slouken@187
   399
					}
slouken@187
   400
				}
slouken@187
   401
			}
slouken@187
   402
		}
slouken@187
   403
	}
slouken@187
   404
	SDL_RWseek(src, start, SEEK_SET);
slouken@187
   405
	return(is_JPG);
slouken@187
   406
}
slouken@187
   407
slouken@187
   408
int IMG_isPNG(SDL_RWops *src)
slouken@187
   409
{
slouken@187
   410
	int start;
slouken@187
   411
	int is_PNG;
slouken@187
   412
	Uint8 magic[4];
slouken@187
   413
	
slouken@187
   414
	if ( !src )
slouken@187
   415
		return 0;
slouken@187
   416
	start = SDL_RWtell(src);
slouken@187
   417
	is_PNG = 0;
slouken@187
   418
	if ( SDL_RWread(src, magic, 1, sizeof(magic)) == sizeof(magic) ) {
slouken@187
   419
		if ( magic[0] == 0x89 &&
slouken@187
   420
			magic[1] == 'P' &&
slouken@187
   421
			magic[2] == 'N' &&
slouken@187
   422
			magic[3] == 'G' ) {
slouken@187
   423
			is_PNG = 1;
slouken@187
   424
		}
slouken@187
   425
	}
slouken@187
   426
	SDL_RWseek(src, start, SEEK_SET);
slouken@187
   427
	return(is_PNG);
slouken@187
   428
}
slouken@187
   429
slouken@187
   430
int IMG_isTIF(SDL_RWops* src)
slouken@187
   431
{
slouken@187
   432
	int start;
slouken@187
   433
	int is_TIF;
slouken@187
   434
	Uint8 magic[4];
slouken@187
   435
	
slouken@187
   436
	if ( !src )
slouken@187
   437
		return 0;
slouken@187
   438
	start = SDL_RWtell(src);
slouken@187
   439
	is_TIF = 0;
slouken@187
   440
	if ( SDL_RWread(src, magic, 1, sizeof(magic)) == sizeof(magic) ) {
slouken@187
   441
		if ( (magic[0] == 'I' &&
slouken@187
   442
			  magic[1] == 'I' &&
slouken@187
   443
		      magic[2] == 0x2a &&
slouken@187
   444
			  magic[3] == 0x00) ||
slouken@187
   445
			(magic[0] == 'M' &&
slouken@187
   446
			 magic[1] == 'M' &&
slouken@187
   447
			 magic[2] == 0x00 &&
slouken@187
   448
			 magic[3] == 0x2a) ) {
slouken@187
   449
			is_TIF = 1;
slouken@187
   450
		}
slouken@187
   451
	}
slouken@187
   452
	SDL_RWseek(src, start, SEEK_SET);
slouken@187
   453
	return(is_TIF);
slouken@187
   454
}
slouken@187
   455
slouken@195
   456
SDL_Surface* IMG_LoadCUR_RW(SDL_RWops *src)
slouken@195
   457
{
slouken@195
   458
	/* FIXME: Is this a supported type? */
slouken@195
   459
	return LoadImageFromRWops(src, CFSTR("com.microsoft.cur"));
slouken@195
   460
}
slouken@195
   461
SDL_Surface* IMG_LoadICO_RW(SDL_RWops *src)
slouken@195
   462
{
slouken@195
   463
	return LoadImageFromRWops(src, kUTTypeICO);
slouken@195
   464
}
slouken@187
   465
SDL_Surface* IMG_LoadBMP_RW(SDL_RWops *src)
slouken@187
   466
{
slouken@187
   467
	return LoadImageFromRWops(src, kUTTypeBMP);
slouken@187
   468
}
slouken@187
   469
SDL_Surface* IMG_LoadGIF_RW(SDL_RWops *src)
slouken@187
   470
{
slouken@187
   471
	return LoadImageFromRWops(src, kUTTypeGIF);
slouken@187
   472
}
slouken@187
   473
SDL_Surface* IMG_LoadJPG_RW(SDL_RWops *src)
slouken@187
   474
{
slouken@187
   475
	return LoadImageFromRWops(src, kUTTypeJPEG);
slouken@187
   476
}
slouken@187
   477
SDL_Surface* IMG_LoadPNG_RW(SDL_RWops *src)
slouken@187
   478
{
slouken@187
   479
	return LoadImageFromRWops(src, kUTTypePNG);
slouken@187
   480
}
slouken@195
   481
SDL_Surface* IMG_LoadTGA_RW(SDL_RWops *src)
slouken@195
   482
{
slouken@195
   483
	return LoadImageFromRWops(src, CFSTR("com.truevision.tga-image"));
slouken@195
   484
}
slouken@187
   485
SDL_Surface* IMG_LoadTIF_RW(SDL_RWops *src)
slouken@187
   486
{
slouken@187
   487
	return LoadImageFromRWops(src, kUTTypeTIFF);
slouken@187
   488
}
slouken@187
   489