Jamie Knight to slouken
authorSam Lantinga <slouken@libsdl.org>
Thu, 08 Apr 2010 23:57:56 -0700
changeset 2498271062b627a
parent 248 9f1019a77946
child 250 692379215a48
Jamie Knight to slouken

Hi Sam,

I'm working on a cross-platform casual game and we're currently evaluating using SDL 1.3 to deploy it for the iPhone.

Some of our textures are currently in tga files current SDL_image built from subversion fails to load on the iPhone. I think I've tracked this down and it is basically because while the ImageIO backend supports TGA, UIImage does not and the fallback code path to use the old RW_ops loaders is broken AND the tga loader is compiled out for ImageIO and UIImage.
IMG_UIImage.m
IMG_tga.c
     1.1 --- a/IMG_UIImage.m	Sat Feb 27 10:24:45 2010 +0000
     1.2 +++ b/IMG_UIImage.m	Thu Apr 08 23:57:56 2010 -0700
     1.3 @@ -114,7 +114,6 @@
     1.4  	SDL_Surface* sdl_surface;
     1.5  	UIImage* ui_image;
     1.6  
     1.7 -	CGImageRef image_ref = NULL;
     1.8  	int bytes_read = 0;
     1.9  	// I don't know what a good size is. 
    1.10  	// Max recommended texture size is 1024x1024 on iPhone so maybe base it on that?
    1.11 @@ -130,11 +129,6 @@
    1.12  		[ns_data appendBytes:temp_buffer length:bytes_read];
    1.13  	} while(bytes_read > 0);
    1.14  
    1.15 -	if(NULL == image_ref)
    1.16 -	{
    1.17 -		return NULL;
    1.18 -	}
    1.19 -
    1.20  	ui_image = [[UIImage alloc] initWithData:ns_data];
    1.21  	
    1.22  	sdl_surface = Create_SDL_Surface_From_CGImage([ui_image CGImage]);
    1.23 @@ -156,8 +150,10 @@
    1.24  	
    1.25  	ns_string = [[NSString alloc] initWithUTF8String:file];
    1.26  	ui_image = [[UIImage alloc] initWithContentsOfFile:ns_string];
    1.27 -	
    1.28 -	sdl_surface = Create_SDL_Surface_From_CGImage([ui_image CGImage]);
    1.29 +	if(ui_image != NULL)
    1.30 +	{
    1.31 +		sdl_surface = Create_SDL_Surface_From_CGImage([ui_image CGImage]);
    1.32 +	}
    1.33  	
    1.34  	[ui_image release];
    1.35  	[ns_string release];
    1.36 @@ -433,10 +429,6 @@
    1.37  {
    1.38  	return LoadImageFromRWops(src, kUTTypePNG);
    1.39  }
    1.40 -SDL_Surface* IMG_LoadTGA_RW(SDL_RWops *src)
    1.41 -{
    1.42 -	return LoadImageFromRWops(src, CFSTR("com.truevision.tga-image"));
    1.43 -}
    1.44  SDL_Surface* IMG_LoadTIF_RW(SDL_RWops *src)
    1.45  {
    1.46  	return LoadImageFromRWops(src, kUTTypeTIFF);
     2.1 --- a/IMG_tga.c	Sat Feb 27 10:24:45 2010 +0000
     2.2 +++ b/IMG_tga.c	Thu Apr 08 23:57:56 2010 -0700
     2.3 @@ -20,10 +20,6 @@
     2.4      slouken@libsdl.org
     2.5  */
     2.6  
     2.7 -#if !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND)
     2.8 -
     2.9 -/* This is a Targa image file loading framework */
    2.10 -
    2.11  #include <stdlib.h>
    2.12  #include <stdio.h>
    2.13  #include <string.h>
    2.14 @@ -333,5 +329,3 @@
    2.15  }
    2.16  
    2.17  #endif /* LOAD_TGA */
    2.18 -
    2.19 -#endif /* !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND) */