Pixels management from SDL_CreateRGBSurfaceFrom

I read in http://wiki.libsdl.org/moin.cgi/SDL_CreateRGBSurfaceFrom
that SDL_CreateRGBSurfaceFrom does not copy pixel, than we should free
pixels data manually.
Is it as designed or bug?

I think manage pixels data in complex application is very very difficult.

Thanks

Hi, it is by design. Think of the following:

You wann do these cool oldschool animations like rotating the palette of
a surface.
So you would create a new surface using SDL_CreateRGBSurfaceFrom from a
surface out of your bag.
The new surface will use the pixeldata of the given surface, then you
would alternate the palette of the new one while the original palette is
unchanged.

So, why it doesnt free the pixeldata automatically? Because it will
destroy the original surface because they share the same memory block.

I know you are making bindung to another language.
I do that for Perl and Perl 6. We are memcopying the pixeldata and
passing the new pointer to that function, to do a safe destroy of our
objects.

Cheers, TobiasAm 30.09.2012 08:33, schrieb wahono sri:

I read in http://wiki.libsdl.org/moin.cgi/SDL_CreateRGBSurfaceFrom
that SDL_CreateRGBSurfaceFrom does not copy pixel, than we should free
pixels data manually.
Is it as designed or bug?

I think manage pixels data in complex application is very very difficult.

Thanks


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

Thanks Tobias for your response. I’ll try it.