imgSavePng function
Save an SDL_Surface into a PNG image file.
If the file already exists, it will be overwritten.
\param surface the SDL surface to save \param file path on the filesystem to write new file to. \returns 0 if successful, -1 on error
\since This function is available since SDL_image 2.0.0.
\sa IMG_SavePNG_RW \sa IMG_SaveJPG \sa IMG_SaveJPG_RW
extern DECLSPEC int SDLCALL IMG_SavePNG(SDL_Surface *surface, const char *file)
Implementation
int imgSavePng(Pointer<SdlSurface> surface, String? file) {
final imgSavePngLookupFunction = libSdl2Image.lookupFunction<
Int32 Function(Pointer<SdlSurface> surface, Pointer<Utf8> file),
int Function(
Pointer<SdlSurface> surface, Pointer<Utf8> file)>('IMG_SavePNG');
final filePointer = file != null ? file.toNativeUtf8() : nullptr;
final result = imgSavePngLookupFunction(surface, filePointer);
calloc.free(filePointer);
return result;
}