Save an SDL surface to a PNG file

Hello,

does anybody know how can I save an SDL surface to a PNG file?
In SDL I’ve only found SDL_SaveBMP.

I’ve also found this code:

http://www.bishoujo.us/svn/renpy/trunk/module/IMG_savepng.c
http://www.bishoujo.us/svn/renpy/trunk/module/IMG_savepng.h

What do you think? Is it safe to use it?
Or does exist a better way to save a surface to PNG?

Thanks in advance for your help

Andrea