screenshots: if compiled with USE_LIBPNG, always use PNG, even for

color-inversed shots. For both PNG and TGA, change the way they're
done in 8-bit mode: instead of XORing every byte with 15, save the
inverse palette (each component taken 255-x).

git-svn-id: https://svn.eduke32.com/eduke32@2219 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-12-28 20:34:10 +00:00
parent d1d94e083f
commit 98bcc0e60c

View file

@ -15415,7 +15415,7 @@ static int32_t screencapture_common1(char *fn, const char *ext, BFILE** filptr)
#ifdef USE_LIBPNG #ifdef USE_LIBPNG
// PNG screenshots -- adapted from libpng example.c // PNG screenshots -- adapted from libpng example.c
int32_t screencapture_png(const char *filename, char inverseit, const char *versionstr) static int32_t screencapture_png(const char *filename, char inverseit, const char *versionstr)
{ {
int32_t i; int32_t i;
BFILE *fp; BFILE *fp;
@ -15434,8 +15434,6 @@ int32_t screencapture_png(const char *filename, char inverseit, const char *vers
char fn[32]; // careful... char fn[32]; // careful...
UNREFERENCED_PARAMETER(inverseit);
Bstrcpy(fn, filename); Bstrcpy(fn, filename);
i = screencapture_common1(fn, "png", &fp); i = screencapture_common1(fn, "png", &fp);
if (i) if (i)
@ -15493,9 +15491,9 @@ int32_t screencapture_png(const char *filename, char inverseit, const char *vers
{ {
for (i=0; i<256; i++) for (i=0; i<256; i++)
{ {
palette[i].red = curpalettefaded[i].r; palette[i].red = inverseit ? 255-curpalettefaded[i].r : curpalettefaded[i].r;
palette[i].green = curpalettefaded[i].g; palette[i].green = inverseit ? 255-curpalettefaded[i].g : curpalettefaded[i].g;
palette[i].blue = curpalettefaded[i].b; palette[i].blue = inverseit ? 255-curpalettefaded[i].b : curpalettefaded[i].b;
} }
png_set_PLTE(png_ptr, info_ptr, palette, 256); png_set_PLTE(png_ptr, info_ptr, palette, 256);
@ -15559,9 +15557,10 @@ int32_t screencapture_png(const char *filename, char inverseit, const char *vers
return 0; return 0;
} }
# undef HICOLOR # undef HICOLOR
#endif // defined USE_LIBPNG
int32_t screencapture_tga(const char *filename, char inverseit) #else // if !defined USE_LIBPNG
static int32_t screencapture_tga(const char *filename, char inverseit)
{ {
int32_t i,j; int32_t i,j;
char *ptr, head[18] = { 0,1,1,0,0,0,1,24,0,0,0,0,0/*wlo*/,0/*whi*/,0/*hlo*/,0/*hhi*/,8,0 }; char *ptr, head[18] = { 0,1,1,0,0,0,1,24,0,0,0,0,0/*wlo*/,0/*whi*/,0/*hlo*/,0/*hhi*/,8,0 };
@ -15605,30 +15604,33 @@ int32_t screencapture_tga(const char *filename, char inverseit)
//getpalette(0,256,palette); //getpalette(0,256,palette);
for (i=0; i<256; i++) for (i=0; i<256; i++)
{ {
Bfputc(curpalettefaded[i].b, fil); // b Bfputc(inverseit ? 255-curpalettefaded[i].b : curpalettefaded[i].b, fil); // b
Bfputc(curpalettefaded[i].g, fil); // g Bfputc(inverseit ? 255-curpalettefaded[i].g : curpalettefaded[i].g, fil); // g
Bfputc(curpalettefaded[i].r, fil); // r Bfputc(inverseit ? 255-curpalettefaded[i].r : curpalettefaded[i].r, fil); // r
} }
# ifdef USE_OPENGL # ifdef USE_OPENGL
} }
# endif # endif
# if 0
// targa renders bottom to top, from left to right // targa renders bottom to top, from left to right
if (inverseit && qsetmode != 200) if (inverseit && qsetmode != 200)
{ {
inversebuf = (char *)Bmalloc(bytesperline); inversebuf = Bmalloc(bytesperline);
if (inversebuf) if (inversebuf)
{ {
for (i=ydim-1; i>=0; i--) for (i=ydim-1; i>=0; i--)
{ {
copybuf(ptr+i*bytesperline, inversebuf, xdim >> 2); Bmemcpy(inversebuf, ptr+i*bytesperline, xdim);
for (j=0; j < (bytesperline>>2); j++)((int32_t *)inversebuf)[j] ^= 0x0f0f0f0fL; for (j=0; j<xdim; j++) /* used to be j<bytesperline */
inversebuf[j] ^= 0x0f;
Bfwrite(inversebuf, xdim, 1, fil); Bfwrite(inversebuf, xdim, 1, fil);
} }
Bfree(inversebuf); Bfree(inversebuf);
} }
} }
else else
# endif
{ {
# ifdef USE_OPENGL # ifdef USE_OPENGL
if (rendmode >= 3 && qsetmode == 200) if (rendmode >= 3 && qsetmode == 200)
@ -15651,13 +15653,11 @@ int32_t screencapture_tga(const char *filename, char inverseit)
} }
} }
else else
{
# endif # endif
{
for (i=ydim-1; i>=0; i--) for (i=ydim-1; i>=0; i--)
Bfwrite(ptr+i*bytesperline, xdim, 1, fil); Bfwrite(ptr+i*bytesperline, xdim, 1, fil);
#ifdef USE_OPENGL
} }
#endif
} }
enddrawing(); //}}} enddrawing(); //}}}
@ -15668,6 +15668,8 @@ int32_t screencapture_tga(const char *filename, char inverseit)
capturecount++; capturecount++;
return(0); return(0);
} }
# endif
#if 0 #if 0
// PCX is nasty, which is why I've lifted these functions from the PCX spec by ZSoft // PCX is nasty, which is why I've lifted these functions from the PCX spec by ZSoft
@ -15841,14 +15843,10 @@ int32_t screencapture(const char *filename, char inverseit, const char *versions
{ {
#ifndef USE_LIBPNG #ifndef USE_LIBPNG
UNREFERENCED_PARAMETER(versionstr); UNREFERENCED_PARAMETER(versionstr);
#else
if (!inverseit)
return screencapture_png(filename,inverseit,versionstr);
else
#endif
// if (captureformat == 0)
return screencapture_tga(filename,inverseit); return screencapture_tga(filename,inverseit);
// else return screencapture_pcx(filename,inverseit); #else
return screencapture_png(filename,inverseit,versionstr);
#endif
} }