save an image using SDL_image?
how can i save a SDL_image to an image file .. i have an image loaded using SDL IMG_Load() method .. i want to now save it in fi开发者_如何学JAVAle ?? i dont want to display it on the surface .. just want to load an image manipulate its pixels and save it back ... dont want to load it on front end ?? so how i can save it to the file ?
was written in some forum 'Not much, at least with SDL_image. SDL_image has only functions for reading images, not for writing images. SDL has SDL_SaveBMP(), but it's hmm just for BMPs. You will need to use another library for writing JPEGs.'
see here
thnks
SDL_image has an undocumented IMG_SavePNG()
and IMG_SavePNG_RW()
. The reason they are undocumented appears to be that they're limited to 32-bit RGBA images, but as this is far and away the most common format, it will likely be enough for your purposes.
You could use a third party library such as corona.
corona::Image* image = corona::OpenImage( "c:/filename.ext", corona::PF_R8G8B8A8 );
// do some stuff with the image...
corona::SaveImage( "c:/filename.ext", PF_R8G8B8A8, image );
delete image;
精彩评论