optional support for PNG screenshots

You need to have SDL2_Image installed and run ./configure --with-sdlimage
This commit is contained in:
Fabian Greffrath 2019-12-20 12:36:50 +01:00
parent 1b0777bd84
commit f4acd9d6bd
6 changed files with 45 additions and 2 deletions

View File

@ -78,5 +78,5 @@ winmbf_SOURCES = \
w_wad.c w_wad.h \
wi_stuff.c wi_stuff.h \
z_zone.c z_zone.h
winmbf_CFLAGS = @SDL_CFLAGS@ @SDL_mixer_CFLAGS@ @SDL_net_CFLAGS@
winmbf_LDADD = @SDL_LIBS@ @SDL_mixer_LIBS@ @SDL_net_LIBS@
winmbf_CFLAGS = @SDL_CFLAGS@ @SDL_image_CFLAGS@ @SDL_mixer_CFLAGS@ @SDL_net_CFLAGS@
winmbf_LDADD = @SDL_LIBS@ @SDL_image_LIBS@ @SDL_mixer_LIBS@ @SDL_net_LIBS@

View File

@ -31,6 +31,11 @@ rcsid[] = "$Id: i_video.c,v 1.12 1998/05/03 22:40:35 killough Exp $";
#include "SDL.h" // haleyjd
#include "config.h"
#ifdef HAVE_SDL_IMAGE
#include "SDL_image.h"
#endif
#include "z_zone.h" /* memory allocation wrappers -- killough */
#include "doomstat.h"
#include "v_video.h"
@ -685,6 +690,13 @@ void I_ShutdownGraphics(void)
}
}
boolean I_WritePNGfile(char *filename)
{
#ifdef HAVE_SDL_IMAGE
return IMG_SavePNG(sdlscreen, filename) == 0;
#endif
}
extern boolean setsizeneeded;
extern void I_InitKeyboard();

View File

@ -60,6 +60,8 @@ extern int page_flip; // killough 8/15/98: enables page flipping (320x200)
extern int disk_icon; // killough 10/98
extern int hires; // killough 11/98
boolean I_WritePNGfile(char *filename);
#endif
//----------------------------------------------------------------------------

View File

@ -3065,7 +3065,11 @@ setup_menu_t gen_settings1[] = { // General Settings screen1
{"Translucency filter percentage", S_NUM, m_null, G_X,
G_Y + general_transpct*8, {"tran_filter_pct"}, 0, 0, M_Trans},
#ifdef HAVE_SDL_IMAGE
{"PCX instead of PNG for screenshots", S_YESNO, m_null, G_X,
#else
{"PCX instead of BMP for screenshots", S_YESNO, m_null, G_X,
#endif
G_Y + general_pcx*8, {"screenshot_pcx"}},
{"Flash Icon During Disk IO", S_YESNO, m_null, G_X,

View File

@ -1031,7 +1031,11 @@ default_t defaults[] = {
"screenshot_pcx",
&screenshot_pcx, NULL,
1, {0,1}, number, ss_gen, wad_no,
#ifdef HAVE_SDL_IMAGE
"1 to take a screenshot in PCX format, 0 for PNG"
#else
"1 to take a screenshot in PCX format, 0 for BMP"
#endif
},
{
@ -2359,6 +2363,12 @@ boolean WriteBMPfile(char *filename, byte *data, int width,
return I_EndRead(), true; // killough 10/98
}
boolean WritePNGfile(char *filename, byte *data, int width,
int height, byte *palette)
{
return I_WritePNGfile(filename);
}
//
// M_ScreenShot
//
@ -2381,7 +2391,11 @@ void M_ScreenShot (void)
do
sprintf(lbmname, //jff 3/30/98 pcx or bmp?
#ifdef HAVE_SDL_IMAGE
screenshot_pcx ? "doom%02d.pcx" : "doom%02d.png", shot++);
#else
screenshot_pcx ? "doom%02d.pcx" : "doom%02d.bmp", shot++);
#endif
while (!access(lbmname,0) && --tries);
if (tries)
@ -2399,7 +2413,11 @@ void M_ScreenShot (void)
// killough 10/98: detect failure and remove file if error
// killough 11/98: add hires support
#ifdef HAVE_SDL_IMAGE
if (!(success = (screenshot_pcx ? WritePCXfile : WritePNGfile)
#else
if (!(success = (screenshot_pcx ? WritePCXfile : WriteBMPfile)
#endif
(lbmname,linear, SCREENWIDTH<<hires, SCREENHEIGHT<<hires,pal)))
{
int t = errno;

View File

@ -17,6 +17,13 @@ PKG_CHECK_MODULES([SDL_mixer], [SDL2_mixer])
PKG_CHECK_MODULES([SDL_net], [SDL2_net])
AC_DEFINE([MY_SDL_VER], [1], [This is WinMBF])
AC_ARG_WITH([sdlimage], AS_HELP_STRING([--with-sdlimage], [Build with SDL2_Image for PNG screenshots]))
AS_IF([test "x$with_sdlimage" = "xyes"],
[PKG_CHECK_MODULES([SDL_image], [SDL2_image],
[AC_DEFINE([HAVE_SDL_IMAGE], [1], [PNG screenshots])]
)]
)
# Checks for header files.
AC_CHECK_HEADERS([fcntl.h limits.h malloc.h stddef.h stdint.h stdlib.h string.h unistd.h])