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