简体   繁体   中英

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 file ?? 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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM