summaryrefslogtreecommitdiff
path: root/render_sdl.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2018-03-24 22:18:23 -0700
committerMichael Pavone <pavone@retrodev.com>2018-03-24 22:18:23 -0700
commit371d5418e6b1bfba88b55382b0a1b91d97023ae5 (patch)
tree26e75e6766ec3f43284b90f3ba5acbf72d78d646 /render_sdl.c
parent484e97a4e318d18b867acea7773853dfc7616a30 (diff)
parent15af9462392967b6adf7ba6ff4f7ff778cf10eb3 (diff)
Merge
--HG-- branch : nuklear_ui
Diffstat (limited to 'render_sdl.c')
-rwxr-xr-xrender_sdl.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/render_sdl.c b/render_sdl.c
index d38947a..db2e091 100755
--- a/render_sdl.c
+++ b/render_sdl.c
@@ -14,6 +14,7 @@
#include "io.h"
#include "util.h"
#include "ppm.h"
+#include "png.h"
#ifndef DISABLE_OPENGL
#include <GL/glew.h>
@@ -604,9 +605,13 @@ void render_framebuffer_updated(uint8_t which, int width)
: 240;
FILE *screenshot_file = NULL;
uint32_t shot_height, shot_width;
+ char *ext;
if (screenshot_path && which == FRAMEBUFFER_ODD) {
screenshot_file = fopen(screenshot_path, "wb");
if (screenshot_file) {
+#ifndef DISABLE_ZLIB
+ ext = path_extension(screenshot_path);
+#endif
info_message("Saving screenshot to %s\n", screenshot_path);
} else {
warning("Failed to open screenshot file %s for writing\n", screenshot_path);
@@ -625,7 +630,17 @@ void render_framebuffer_updated(uint8_t which, int width)
if (screenshot_file) {
//properly supporting interlaced modes here is non-trivial, so only save the odd field for now
- save_ppm(screenshot_file, texture_buf, shot_width, shot_height, LINEBUF_SIZE*sizeof(uint32_t));
+#ifndef DISABLE_ZLIB
+ if (!strcasecmp(ext, "png")) {
+ free(ext);
+ save_png(screenshot_file, texture_buf, shot_width, shot_height, LINEBUF_SIZE*sizeof(uint32_t));
+ } else {
+ free(ext);
+#endif
+ save_ppm(screenshot_file, texture_buf, shot_width, shot_height, LINEBUF_SIZE*sizeof(uint32_t));
+#ifndef DISABLE_ZLIB
+ }
+#endif
}
} else {
#endif
@@ -652,7 +667,17 @@ void render_framebuffer_updated(uint8_t which, int width)
} else {
shot_pitch *= 2;
}
- save_ppm(screenshot_file, locked_pixels, shot_width, shot_height, shot_pitch);
+#ifndef DISABLE_ZLIB
+ if (!strcasecmp(ext, "png")) {
+ free(ext);
+ save_png(screenshot_file, locked_pixels, shot_width, shot_height, shot_pitch);
+ } else {
+ free(ext);
+#endif
+ save_ppm(screenshot_file, locked_pixels, shot_width, shot_height, shot_pitch);
+#ifndef DISABLE_ZLIB
+ }
+#endif
}
SDL_UnlockTexture(sdl_textures[which]);
#ifndef DISABLE_OPENGL