Duplicate Image Data

i’m trying to create an exact duplicate of some surface data.
for some reason this is harder than it seems. what is making it
tricky is that i want it to work with all surfaces types
(alphas, colorkeys, etc)

I’ve seen SDL_CreateRGBSurfaceFrom(…), but this only
shared the image data with the original surface. i want
a new copy of the data that is mine to bend at will.

Why is this harder than I keep thinking? What boulder is
caught in my eye to prevent me from seeing it?

Could someone post the code to do this…? (big thanks!)

i’m trying to create an exact duplicate of some surface data.
for some reason this is harder than it seems. what is making it
tricky is that i want it to work with all surfaces types
(alphas, colorkeys, etc)

newsurface = SDL_ConvertSurface(surface, surface->format, surface->flags)