summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKikooDX <kikoodx@paranoici.org>2022-08-31 15:31:05 +0200
committerKikooDX <kikoodx@paranoici.org>2022-08-31 15:31:05 +0200
commitdb5dfef1521ebc695559ccaf365ba472ec5b0754 (patch)
treef90eadecd345d525a6805cced9f9bbc0fec2b470
parentfa48a066f7f3ac9f76fae15d1a1c1d0609601c2d (diff)
downloadscr16-db5dfef1521ebc695559ccaf365ba472ec5b0754.tar.gz
png screenshots
-rw-r--r--Tupfile2
-rw-r--r--render.c3
-rw-r--r--screenshot.c2
-rw-r--r--sdl_init.c6
4 files changed, 10 insertions, 3 deletions
diff --git a/Tupfile b/Tupfile
index 4b79783..dfc3d58 100644
--- a/Tupfile
+++ b/Tupfile
@@ -1,6 +1,6 @@
CC = gcc
CFLAGS = -Os -std=c99 `sdl2-config --cflags`
-LIBS = -lm -ldx `sdl2-config --libs`
+LIBS = -lm -ldx `sdl2-config --libs` -lSDL2_image
.gitignore
: beep.wav |> cembed -s -t beep_info -o %o %f |> beep.c
diff --git a/render.c b/render.c
index 48f5de4..1300d5a 100644
--- a/render.c
+++ b/render.c
@@ -2,6 +2,7 @@
#include "sdl_init.h"
#include "texture.h"
#include <SDL2/SDL.h>
+#include <SDL2/SDL_image.h>
#include <dx/log.h>
#include <stdint.h>
@@ -102,7 +103,7 @@ void r_screenshot(const char *path)
}
SDL_RenderReadPixels(renderer, NULL, surface->format->format,
surface->pixels, surface->pitch);
- SDL_SaveBMP(surface, path);
+ IMG_SavePNG(surface, path);
SDL_FreeSurface(surface);
}
diff --git a/screenshot.c b/screenshot.c
index ed04816..50fbf7f 100644
--- a/screenshot.c
+++ b/screenshot.c
@@ -9,7 +9,7 @@ void screenshot(void)
sfd_Options opt = {
.title = "Save Screenshot",
.filter_name = "Image File",
- .filter = "*.bmp",
+ .filter = "*.png",
};
const char *filename = sfd_save_dialog(&opt);
if (filename == NULL)
diff --git a/sdl_init.c b/sdl_init.c
index b7afe29..35cbd25 100644
--- a/sdl_init.c
+++ b/sdl_init.c
@@ -1,5 +1,6 @@
#include "sdl_init.h"
#include <SDL2/SDL.h>
+#include <SDL2/SDL_image.h>
#include <dx/log.h>
int sdl_init(void)
@@ -8,10 +9,15 @@ int sdl_init(void)
dx_log_error("%s", SDL_GetError());
return 1;
}
+ if (IMG_Init(IMG_INIT_PNG) == 0) {
+ dx_log_error("%s", IMG_GetError());
+ return 1;
+ }
return 0;
}
void sdl_deinit(void)
{
+ IMG_Quit();
SDL_Quit();
}