简体   繁体   English

使用SDL_image保存图像?

[英]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 ?? 如何将SDL_image保存到图像文件..我已使用SDL IMG_Load()方法加载了图像..我现在要将其保存在文件中? 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上不多。 SDL_image has only functions for reading images, not for writing images. SDL_image仅具有读取图像的功能,而没有写入图像的功能。 SDL has SDL_SaveBMP(), but it's hmm just for BMPs. SDL具有SDL_SaveBMP(),但仅适用于BMP。 You will need to use another library for writing JPEGs.' 您将需要使用另一个库来编写JPEG。

see here 看这里

thnks 谢谢

SDL_image has an undocumented IMG_SavePNG() and IMG_SavePNG_RW() . SDL_image具有未记录的IMG_SavePNG()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. 它们没有被记录的原因似乎是它们仅限于32位RGBA图像,但是由于这是最常见的格式,因此对于您的目的来说可能就足够了。

You could use a third party library such as corona . 您可以使用第三方库,例如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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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