IMG_Load_RW

For some reason IMG_Load_RW is reporting unsupported type however, if I write it to a file, I can load it fine with a normal IMG_Load(). Any hints on why it won’t load with IMG_Load_RW ?

Here’s the relevant code.

SDL_RWops * picData = SDL_RWFromMem(pic->picture().data(),pic->picture().size());

///temp write to disk to examine jpeg:
ofstream temppic;
temppic.open("/tmp/album-image.jpg",ios::binary | ios::trunc);

if(temppic)
{
    temppic.write(pic->picture().data(),pic->picture().size());
    temppic.close();
}

if(!picData)
{
    ndebug::out(ndebug::LOG_DEBUG,"SearchDir: failed to conver album art into SDL RWop for %s",path.c_str());
    return NULL;
}

SDL_Surface * image;

   /// This works:
image = IMG_Load("/tmp/album-image.jpg");

/// This doesn’t work:
//image = IMG_Load_RW(picData,1);

if(!image)
{
    ndebug::out(ndebug::LOG_ERR,"SearchDir: Failed to load album art image.  Error: (%s)",IMG_GetError());
    ndebug::out(ndebug::LOG_ERR,"SearchDir: mime type of image: %s",pic->mimeType().toCString());
    
    return NULL;
}

return image;
   /// This works:
image = IMG_Load("/tmp/album-image.jpg");

/// This doesn’t work:
//image = IMG_Load_RW(picData,1);

It doesn’t make any sense to me, did you try debugging it?

See ya,
-Sam Lantinga, Lead Software Engineer, Blizzard Entertainment

   /// This works:
image = IMG_Load("/tmp/album-image.jpg");

/// This doesn’t work:
//image = IMG_Load_RW(picData,1);

It doesn’t make any sense to me, did you try debugging it?

It doesn’t make sense to me either ;). I’m writing to disk the exact memory space that I’m creating the RWop with:

SDL_RWops * picData = SDL_RWFromMem(pic->picture().data(),pic->picture().size());

ofstream temppic;
temppic.open("/tmp/album-image.jpg",ios::binary | ios::trunc);

if(temppic)
{
temppic.write(pic->picture().data(),pic->picture().size());
temppic.close();
}

The image that I write to the disk works, but the RWop doesn’t…

Is there an environment variable that I can use to turn on SDL debugging? or do I have to compile that in?

SDL 1.2.13
SDL_Image 1.2.6

   /// This works:
image = IMG_Load("/tmp/album-image.jpg");

/// This doesn’t work:
//image = IMG_Load_RW(picData,1);

It doesn’t make any sense to me, did you try debugging it?

It doesn’t make sense to me either ;). I’m writing to disk the exact memory space that I’m creating the RWop with:

SDL_RWops * picData = SDL_RWFromMem(pic->picture().data(),pic->picture().size());

ofstream temppic;
temppic.open("/tmp/album-image.jpg",ios::binary | ios::trunc);

if(temppic)
{
temppic.write(pic->picture().data(),pic->picture().size());
temppic.close();
}

The image that I write to the disk works, but the RWop doesn’t…

Is there an environment variable that I can use to turn on SDL debugging? or do I have to compile that in?

SDL 1.2.13
SDL_Image 1.2.6