Anyone using SDL_Image on iPhone?

I’ve just started porting a 2D Mac/Windows game to iPhone. Currently running into an issue where SDL_Image isn’t loading the image…

ops = SDL_RWFromFile(filename, “rb”);
if (ops != NULL)
tempSurfaceP = IMG_Load_RW(ops, 0);

return a NULL pointer in tempSurfaceP, even though the file was successfully opened with SDL_RWFromFile().

When I instead use SDL’s built-in methods to load a .tga or .bmp, it works fine. But SDL_Image fails.

A call to SDL_GetError() after this returns an empty or null string.

Are there any demo/example programs out there that successfully use SDL_Image? All the demos that come in the “Demos” folder with SDL 1.3 use the built-in methods, not SDL_Image.

Are you using a SDL 1.3 version of SDL_image?

Jonny DOn Fri, Jan 13, 2012 at 2:46 PM, VernJensen wrote:

**
I’ve just started porting a 2D Mac/Windows game to iPhone. Currently
running into an issue where SDL_Image isn’t loading the image…

ops = SDL_RWFromFile(filename, “rb”);
if (ops != NULL)
tempSurfaceP = IMG_Load_RW(ops, 0);

return a NULL pointer in tempSurfaceP, even though the file was
successfully opened with SDL_RWFromFile().

When I instead use SDL’s built-in methods to load a .tga or .bmp, it works
fine. But SDL_Image fails.

A call to SDL_GetError() after this returns an empty or null string.

Are there any demo/example programs out there that successfully use
SDL_Image? All the demos that come in the “Demos” folder with SDL 1.3 use
the built-in methods, not SDL_Image.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I found this thread:

http://forums.libsdl.org/viewtopic.php?t=7112&sid=066bd713673b6fe700614652d39eed48

I didn’t realize a Mercurial repository was available for SDL_Image. I had thought 1.2.10 was the absolutely latest version. Apparently not by a longshot! I’m downloading the latest from Mercurial right now, and expect that this will fix the issue.

Okay, that didn’t fix the problem. Even using the very latest SDL_Image from Mercurial it still has the same issue.

Any suggestions?

Nevermind, got it working. Was an issue with XCode where XCode does not properly handle the fact that you changed a static library, even if you remove and add it back to the project. Somehow it still uses the data from the old library, even if you “Touch” it. I got around the problem by renaming the library – this successfully triggers XCode to realize it’s now different. And now it works. :slight_smile:

VernJensen wrote:

I’ve just started porting a 2D Mac/Windows game to iPhone. Currently running into an issue where SDL_Image isn’t loading the image…

ops = SDL_RWFromFile(filename, “rb”);
if (ops != NULL)
tempSurfaceP = IMG_Load_RW(ops, 0);

I had similar problems (segfaults) on Android when using SDL_RWFromFile.
I ended up converting the image(s) to xpm (imagemagick’s convert tool
does that) which basically converts the image into a source file. Then
include that in your app.

Example of part of the image xpm source file:

/* XPM */
static char shape_[] = {
/
columns rows colors chars-per-pixel */
“34 34 31 1”,
" c #000000",
". c #040404",

Main source:

#include “shape.xpm”

/* … */

SDL_Surface *temp;
temp=IMG_ReadXPMFromArray(shape_);

/* in SDL 1.3 you would go on converting temp to a texture */–
Earthquake Magnitude: 4.7
Date: Friday, January 13, 2012 19:46:09 UTC
Location: Queen Charlotte Islands, Canada region
Latitude: 51.2617; Longitude: -130.3610
Depth: 15.00 km