---
name: "IMG_SavePNG_IO"
section: "3"
platform: "linux"
package: "libsdl3-image-doc"
version: "3.2.4+ds-1+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/IMG_SavePNG_IO"
---

# IMG\_SavePNG\_IO(3)

Save an SDL\_Surface into PNG image data, via an SDL\_IOStream.

## NAME

IMG\_SavePNG\_IO - Save an SDL\_Surface into PNG image data, via an SDL\_IOStream.

## HEADER FILE

Defined in SDL3\_image/SDL\_image.h

## SYNOPSIS

```
#include "SDL3_image/SDL_image.h"
```

**bool IMG\_SavePNG\_IO(SDL\_Surface \*surface, SDL\_IOStream \*dst, bool closeio);**

## DESCRIPTION

If you just want to save to a filename, you can use

**IMG\_SavePNG** () instead.

If **closeio** is true, **dst** will be closed before returning, whether this function succeeds or not.

## FUNCTION PARAMETERS

- *surface*

  the SDL surface to save.

- *dst*

  the SDL\_IOStream to save the image data to.

- *closeio*

  true to close/free the SDL\_IOStream before returning, false to leave it open.

## RETURN VALUE

Returns true on success or false on failure; call SDL\_GetError() for more information.

## AVAILABILITY

This function is available since SDL\_image 3.0.0.

## SEE ALSO

**•**(3), [**IMG\_SavePNG**(3)](/IMG_SavePNG/3.md)
