summaryrefslogtreecommitdiff
path: root/sdl2/image.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2016-12-16 15:49:58 -0500
committerDavid Thompson <dthompson2@worcester.edu>2016-12-16 21:52:36 -0500
commit0c8dc41d9f8da0dae8a171880efd9de3010328a1 (patch)
treef842fd2fac1a69abeb83edc328d2bcc1e05752b5 /sdl2/image.scm
parent53eb88ff721968299dd59e1c604e1b5714c5f0a5 (diff)
image: Add IMG_SavePNG binding.
Diffstat (limited to 'sdl2/image.scm')
-rw-r--r--sdl2/image.scm9
1 files changed, 8 insertions, 1 deletions
diff --git a/sdl2/image.scm b/sdl2/image.scm
index e741a04..ba0119b 100644
--- a/sdl2/image.scm
+++ b/sdl2/image.scm
@@ -29,7 +29,8 @@
#:use-module ((sdl2 bindings image) #:prefix ffi:)
#:export (image-init
image-quit
- load-image))
+ load-image
+ save-png))
(define (image-init)
"Initialize dynamically loaded image libraries."
@@ -49,3 +50,9 @@
(if (null-pointer? ptr)
(sdl-error "load-image" "failed to load image: ~a" file)
((@@ (sdl2 surface) wrap-surface) ptr))))
+
+(define (save-png surface file)
+ "Save SURFACE to FILE as a PNG formatted image."
+ (unless (zero? (ffi:img-save-png ((@@ (sdl2 surface) unwrap-surface) surface)
+ (string->pointer file)))
+ (sdl-error "save-png" "failed to save surface as PNG: ~a" file)))