From aa68c6e546c10313a24726a4fcc440872f299861 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 8 Apr 2010 23:57:56 -0700 Subject: [PATCH] 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 | 16 ++++------------ IMG_tga.c | 6 ------ 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/IMG_UIImage.m b/IMG_UIImage.m index 2250a6d4..b7af059b 100644 --- a/IMG_UIImage.m +++ b/IMG_UIImage.m @@ -114,7 +114,6 @@ SDL_Surface* sdl_surface; UIImage* ui_image; - CGImageRef image_ref = NULL; int bytes_read = 0; // I don't know what a good size is. // Max recommended texture size is 1024x1024 on iPhone so maybe base it on that? @@ -130,11 +129,6 @@ [ns_data appendBytes:temp_buffer length:bytes_read]; } while(bytes_read > 0); - if(NULL == image_ref) - { - return NULL; - } - ui_image = [[UIImage alloc] initWithData:ns_data]; sdl_surface = Create_SDL_Surface_From_CGImage([ui_image CGImage]); @@ -156,8 +150,10 @@ ns_string = [[NSString alloc] initWithUTF8String:file]; ui_image = [[UIImage alloc] initWithContentsOfFile:ns_string]; - - sdl_surface = Create_SDL_Surface_From_CGImage([ui_image CGImage]); + if(ui_image != NULL) + { + sdl_surface = Create_SDL_Surface_From_CGImage([ui_image CGImage]); + } [ui_image release]; [ns_string release]; @@ -433,10 +429,6 @@ int IMG_isTIF(SDL_RWops* src) { return LoadImageFromRWops(src, kUTTypePNG); } -SDL_Surface* IMG_LoadTGA_RW(SDL_RWops *src) -{ - return LoadImageFromRWops(src, CFSTR("com.truevision.tga-image")); -} SDL_Surface* IMG_LoadTIF_RW(SDL_RWops *src) { return LoadImageFromRWops(src, kUTTypeTIFF); diff --git a/IMG_tga.c b/IMG_tga.c index c298cdd4..fd580526 100644 --- a/IMG_tga.c +++ b/IMG_tga.c @@ -20,10 +20,6 @@ slouken@libsdl.org */ -#if !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND) - -/* This is a Targa image file loading framework */ - #include #include #include @@ -333,5 +329,3 @@ SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src) } #endif /* LOAD_TGA */ - -#endif /* !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND) */