diff options
author | KikooDX <kikoodx@paranoici.org> | 2022-08-31 15:31:05 +0200 |
---|---|---|
committer | KikooDX <kikoodx@paranoici.org> | 2022-08-31 15:31:05 +0200 |
commit | db5dfef1521ebc695559ccaf365ba472ec5b0754 (patch) | |
tree | f90eadecd345d525a6805cced9f9bbc0fec2b470 | |
parent | fa48a066f7f3ac9f76fae15d1a1c1d0609601c2d (diff) | |
download | scr16-db5dfef1521ebc695559ccaf365ba472ec5b0754.tar.gz |
png screenshots
-rw-r--r-- | Tupfile | 2 | ||||
-rw-r--r-- | render.c | 3 | ||||
-rw-r--r-- | screenshot.c | 2 | ||||
-rw-r--r-- | sdl_init.c | 6 |
4 files changed, 10 insertions, 3 deletions
@@ -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 @@ -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) @@ -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(); } |