mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-29 20:50:58 +00:00
Screenshots now contain the palette you're actively looking at, as opposed to the palette the game/map has! This makes sense for colorblind users being able to store their precious memories, and it matches up with how gifs palettise.
This commit is contained in:
parent
29d5af61c1
commit
9d46ba281f
3 changed files with 13 additions and 16 deletions
|
@ -789,7 +789,7 @@ boolean HWR_Screenshot(const char *lbmname)
|
|||
HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (void *)buf);
|
||||
|
||||
#ifdef USE_PNG
|
||||
ret = M_SavePNG(lbmname, buf, vid.width, vid.height, NULL);
|
||||
ret = M_SavePNG(lbmname, buf, vid.width, vid.height, false);
|
||||
#else
|
||||
ret = saveTGA(lbmname, buf, vid.width, vid.height);
|
||||
#endif
|
||||
|
|
25
src/m_misc.c
25
src/m_misc.c
|
@ -610,19 +610,18 @@ static void PNG_warn(png_structp PNG, png_const_charp pngtext)
|
|||
CONS_Debug(DBG_RENDER, "libpng warning at %p: %s", PNG, pngtext);
|
||||
}
|
||||
|
||||
static void M_PNGhdr(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png_uint_32 width, PNG_CONST png_uint_32 height, PNG_CONST png_byte *palette)
|
||||
static void M_PNGhdr(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png_uint_32 width, PNG_CONST png_uint_32 height, const boolean palette)
|
||||
{
|
||||
const png_byte png_interlace = PNG_INTERLACE_NONE; //PNG_INTERLACE_ADAM7
|
||||
if (palette)
|
||||
{
|
||||
png_colorp png_PLTE = png_malloc(png_ptr, sizeof(png_color)*256); //palette
|
||||
const png_byte *pal = palette;
|
||||
png_uint_16 i;
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
png_PLTE[i].red = *pal; pal++;
|
||||
png_PLTE[i].green = *pal; pal++;
|
||||
png_PLTE[i].blue = *pal; pal++;
|
||||
png_PLTE[i].red = pLocalPalette[i].s.red;
|
||||
png_PLTE[i].green = pLocalPalette[i].s.green;
|
||||
png_PLTE[i].blue = pLocalPalette[i].s.blue;
|
||||
}
|
||||
png_set_IHDR(png_ptr, png_info_ptr, width, height, 8, PNG_COLOR_TYPE_PALETTE,
|
||||
png_interlace, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
@ -924,7 +923,7 @@ static void M_PNGfix_acTL(png_structp png_ptr, png_infop png_info_ptr)
|
|||
fseek(apng_FILE, oldpos, SEEK_SET);
|
||||
}
|
||||
|
||||
static boolean M_SetupaPNG(png_const_charp filename, png_bytep pal)
|
||||
static boolean M_SetupaPNG(png_const_charp filename, boolean palette)
|
||||
{
|
||||
apng_FILE = fopen(filename,"wb+"); // + mode for reading
|
||||
if (!apng_FILE)
|
||||
|
@ -966,7 +965,7 @@ static boolean M_SetupaPNG(png_const_charp filename, png_bytep pal)
|
|||
png_set_compression_strategy(apng_ptr, cv_zlib_strategya.value);
|
||||
png_set_compression_window_bits(apng_ptr, cv_zlib_window_bitsa.value);
|
||||
|
||||
M_PNGhdr(apng_ptr, apng_info_ptr, vid.width, vid.height, pal);
|
||||
M_PNGhdr(apng_ptr, apng_info_ptr, vid.width, vid.height, palette);
|
||||
|
||||
M_PNGText(apng_ptr, apng_info_ptr, true);
|
||||
|
||||
|
@ -1007,9 +1006,9 @@ static inline moviemode_t M_StartMovieAPNG(const char *pathname)
|
|||
}
|
||||
|
||||
if (rendermode == render_soft)
|
||||
ret = M_SetupaPNG(va(pandf,pathname,freename), W_CacheLumpName(GetPalette(), PU_CACHE));
|
||||
ret = M_SetupaPNG(va(pandf,pathname,freename), true);
|
||||
else
|
||||
ret = M_SetupaPNG(va(pandf,pathname,freename), NULL);
|
||||
ret = M_SetupaPNG(va(pandf,pathname,freename), false);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
|
@ -1215,11 +1214,10 @@ void M_StopMovie(void)
|
|||
* \param palette Palette of image data
|
||||
* \note if palette is NULL, BGR888 format
|
||||
*/
|
||||
boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette)
|
||||
boolean M_SavePNG(const char *filename, void *data, int width, int height, const boolean palette)
|
||||
{
|
||||
png_structp png_ptr;
|
||||
png_infop png_info_ptr;
|
||||
PNG_CONST png_byte *PLTE = (const png_byte *)palette;
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
jmp_buf jmpbuf;
|
||||
|
@ -1282,7 +1280,7 @@ boolean M_SavePNG(const char *filename, void *data, int width, int height, const
|
|||
png_set_compression_strategy(png_ptr, cv_zlib_strategy.value);
|
||||
png_set_compression_window_bits(png_ptr, cv_zlib_window_bits.value);
|
||||
|
||||
M_PNGhdr(png_ptr, png_info_ptr, width, height, PLTE);
|
||||
M_PNGhdr(png_ptr, png_info_ptr, width, height, palette);
|
||||
|
||||
M_PNGText(png_ptr, png_info_ptr, false);
|
||||
|
||||
|
@ -1445,8 +1443,7 @@ void M_DoScreenShot(void)
|
|||
if (rendermode != render_none)
|
||||
{
|
||||
#ifdef USE_PNG
|
||||
ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height,
|
||||
W_CacheLumpName(GetPalette(), PU_CACHE));
|
||||
ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height, true);
|
||||
#else
|
||||
ret = WritePCXfile(va(pandf,pathname,freename), linear, vid.width, vid.height,
|
||||
W_CacheLumpName(GetPalette(), PU_CACHE));
|
||||
|
|
|
@ -64,7 +64,7 @@ void FIL_ForceExtension(char *path, const char *extension);
|
|||
boolean FIL_CheckExtension(const char *in);
|
||||
|
||||
#ifdef HAVE_PNG
|
||||
boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette);
|
||||
boolean M_SavePNG(const char *filename, void *data, int width, int height, const boolean palette);
|
||||
#endif
|
||||
|
||||
extern boolean takescreenshot;
|
||||
|
|
Loading…
Reference in a new issue