mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-01-26 00:16:23 +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.
(cherry picked from commit 9d46ba281f)
This commit is contained in:
parent
cdf8c54f2d
commit
56ac088443
3 changed files with 13 additions and 16 deletions
|
|
@ -1208,7 +1208,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
|
|
@ -654,19 +654,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);
|
||||
|
|
@ -941,7 +940,7 @@ static void M_PNGfix_acTL(png_structp png_ptr, png_infop png_info_ptr,
|
|||
#endif
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
@ -993,7 +992,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);
|
||||
|
||||
|
|
@ -1033,9 +1032,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)
|
||||
{
|
||||
|
|
@ -1241,11 +1240,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;
|
||||
|
|
@ -1308,7 +1306,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);
|
||||
|
||||
|
|
@ -1471,8 +1469,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…
Add table
Reference in a new issue