PNG Transparency is black on iPhone

Hello Everyone,
I have been racking my brain for days on this one. I am porting a game from Mac OS X to iPhone using the latest SDL and SDL_image libraries and I am having problems with the code below. The function loads in an image used for animation, grabs part of that image and places it on a 64x64 surface.

Code:
SDL_Surface *
Load_Block (char *filename, int line, int col, SDL_Rect * block, int flags)
{
static SDL_Surface *pic = NULL;
SDL_Surface *tmp;
SDL_Rect src, dim;
SDL_Surface *ret;
int usealpha;

if (!filename && !pic) /* we need some info… */
return (NULL);

if (filename) // initialize: read & malloc new pic, dont’ return a copy!!
{
if (pic) // previous pic?
SDL_FreeSurface (pic);
pic = IMG_Load (filename);

}

if ( (flags & INIT_ONLY) != FALSE )
return (NULL); // that’s it guys, only initialzing…

if (!block)
{
Set_Rect (dim, 0, 0, pic->w, pic->h); // pic can be any size. Should at least be 0, 0, 64, 64
}
else
{
Set_Rect (dim, 0, 0, block->w, block->h); // block is 0, 0, 64, 64
}

if (pic->format->Amask != 0)
usealpha = TRUE; // png images do have transparent backgrounds
else
usealpha = FALSE;

if (usealpha)
SDL_SetAlpha (pic, 0, 0); /* clear per-surf alpha for internal blit */
tmp = SDL_CreateRGBSurface (0, dim.w, dim.h, screen_bpp, 0, 0, 0, 0);
if (usealpha)
ret = SDL_DisplayFormatAlpha (tmp);
else
ret = SDL_DisplayFormat (tmp);
SDL_FreeSurface (tmp);

Set_Rect (src, col * (dim.w + 2), line * (dim.h + 2), dim.w, dim.h);
SDL_BlitSurface (pic, &src, ret, NULL);
if (usealpha)
SDL_SetAlpha (ret, SDL_SRCALPHA | SDL_RLEACCEL, SDL_ALPHA_OPAQUE);

return (ret);

} // Load_Block()

I do remember reading somewhere about iPhone swapping the Red and Blue channels, but I don’t think that is the problem. I can blit other png images with no problems. The problem appears to be with SDL_CreateRGBSurface. From all of the other discussions I have read, it would seem that the modified code below should work, but it doesn’t. Can a fresh set of eyes please tell me what I am missing?

Code:
SDL_Surface *
Load_Block (char *filename, int line, int col, SDL_Rect *block, int flags)
{
static SDL_Surface *pic = NULL;
SDL_Surface *tmp;
SDL_Rect src, dim;
SDL_Surface *ret;
int usealpha;

/* Create a 32-bit surface with the bytes of each pixel in R,G,B,A order,
 as expected by OpenGL for textures */
Uint32 rmask, gmask, bmask, amask;

/* SDL interprets each pixel as a 32-bit number, so our masks must depend
 on the endianness (byte order) of the machine */

#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
#else
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
#endif

if (!filename && !pic) {			// We need some info...
	return (NULL);
}

if (filename) {		// Initialize: read & malloc new pic, don't return a copy!!
	if (pic)		// previous pic?
		SDL_FreeSurface(pic);
	pic = IMG_Load(filename);
}

if ((flags & INIT_ONLY) != FALSE) {
	return (NULL);	// That's it guys, only initializing...
}

if (!block) {
	Set_Rect (dim, 0, 0, pic->w, pic->h);        // pic can be any size. Should at least be 0, 0, 64, 64
} else {
	Set_Rect (dim, 0, 0, block->w, block->h);    // block is 0, 0, 64, 64
}

if (pic->format->Amask != 0) {
	usealpha = TRUE;                    // png images do have transparent backgrounds
} else {
	usealpha = FALSE;
}

if (usealpha) {
	SDL_SetAlpha(pic, 0, 0);	// clear per-surf alpha for internal blit
}
tmp = SDL_CreateRGBSurface(SDL_HWSURFACE, dim.w, dim.h, screen_bpp, bmask, gmask, rmask, amask);        // Everyone says to use mask values
tmp = SDL_ConvertSurface(tmp, pic->format, SDL_HWSURFACE | SDL_SRCALPHA);          // Some say it is a conversion issue. Doesn't work with it or with out it.
if (usealpha) {
	ret = SDL_DisplayFormatAlpha(tmp);
} else {
	ret = SDL_DisplayFormat(tmp);
}
SDL_FreeSurface(tmp);
Set_Rect (src, col * (dim.w + 2), line * (dim.h + 2), dim.w, dim.h);
//SDL_SetColorKey(pic, SDL_SRCCOLORKEY | SDL_RLEACCEL, GetPixel(pic, 0, 0));        // I thought this might work, but was wrong.
SDL_BlitSurface (pic, &src, ret, NULL);
if (usealpha) {
	SDL_SetAlpha(ret, SDL_SRCALPHA | SDL_RLEACCEL, SDL_ALPHA_OPAQUE);
}
	
return (ret);

} // Load_Block

Thanks for your assistance.
Rick