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
// 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;
BFILE *fp;
@ -15434,8 +15434,6 @@ int32_t screencapture_png(const char *filename, char inverseit, const char *vers
char fn[32]; // careful...
UNREFERENCED_PARAMETER(inverseit);
Bstrcpy(fn, filename);
i = screencapture_common1(fn, "png", &fp);
if (i)
@ -15493,9 +15491,9 @@ int32_t screencapture_png(const char *filename, char inverseit, const char *vers
{
for (i=0; i<256; i++)
{
palette[i].red = curpalettefaded[i].r;
palette[i].green = curpalettefaded[i].g;
palette[i].blue = curpalettefaded[i].b;
palette[i].red = inverseit ? 255-curpalettefaded[i].r : curpalettefaded[i].r;
palette[i].green = inverseit ? 255-curpalettefaded[i].g : curpalettefaded[i].g;
palette[i].blue = inverseit ? 255-curpalettefaded[i].b : curpalettefaded[i].b;
}
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;
}
# 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;
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);
for (i=0; i<256; i++)
{
Bfputc(curpalettefaded[i].b, fil); // b
Bfputc(curpalettefaded[i].g, fil); // g
Bfputc(curpalettefaded[i].r, fil); // r
Bfputc(inverseit ? 255-curpalettefaded[i].b : curpalettefaded[i].b, fil); // b
Bfputc(inverseit ? 255-curpalettefaded[i].g : curpalettefaded[i].g, fil); // g
Bfputc(inverseit ? 255-curpalettefaded[i].r : curpalettefaded[i].r, fil); // r
}
# ifdef USE_OPENGL
}
# endif
# if 0
// targa renders bottom to top, from left to right
if (inverseit && qsetmode != 200)
{
inversebuf = (char *)Bmalloc(bytesperline);
inversebuf = Bmalloc(bytesperline);
if (inversebuf)
{
for (i=ydim-1; i>=0; i--)
{
copybuf(ptr+i*bytesperline, inversebuf, xdim >> 2);
for (j=0; j < (bytesperline>>2); j++)((int32_t *)inversebuf)[j] ^= 0x0f0f0f0fL;
Bmemcpy(inversebuf, ptr+i*bytesperline, xdim);
for (j=0; j<xdim; j++) /* used to be j<bytesperline */
inversebuf[j] ^= 0x0f;
Bfwrite(inversebuf, xdim, 1, fil);
}
Bfree(inversebuf);
}
}
else
# endif
{
# ifdef USE_OPENGL
if (rendmode >= 3 && qsetmode == 200)
@ -15651,13 +15653,11 @@ int32_t screencapture_tga(const char *filename, char inverseit)
}
}
else
{
# endif
{
for (i=ydim-1; i>=0; i--)
Bfwrite(ptr+i*bytesperline, xdim, 1, fil);
#ifdef USE_OPENGL
}
#endif
}
enddrawing(); //}}}
@ -15668,6 +15668,8 @@ int32_t screencapture_tga(const char *filename, char inverseit)
capturecount++;
return(0);
}
# endif
#if 0
// 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
UNREFERENCED_PARAMETER(versionstr);
#else
if (!inverseit)
return screencapture_png(filename,inverseit,versionstr);
else
#endif
// if (captureformat == 0)
return screencapture_tga(filename,inverseit);
// else return screencapture_pcx(filename,inverseit);
#else
return screencapture_png(filename,inverseit,versionstr);
#endif
}