mirror of
https://github.com/nzp-team/fteqw.git
synced 2025-01-18 14:31:52 +00:00
add scr_sshot_compression, sets level for png/jpg compression, ranges from 0-100 defaults to 75
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2330 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
177b95f346
commit
0b62fbba57
3 changed files with 11 additions and 7 deletions
|
@ -106,6 +106,7 @@ extern cvar_t scr_showpause;
|
|||
extern cvar_t scr_printspeed;
|
||||
extern cvar_t scr_allowsnap;
|
||||
extern cvar_t scr_sshot_type;
|
||||
extern cvar_t scr_sshot_compression;
|
||||
extern cvar_t crosshair;
|
||||
extern cvar_t scr_consize;
|
||||
|
||||
|
@ -1643,7 +1644,7 @@ typedef struct _TargaHeader {
|
|||
|
||||
|
||||
#ifdef AVAIL_JPEGLIB
|
||||
void screenshotJPEG(char *filename, qbyte *screendata, int screenwidth, int screenheight);
|
||||
void screenshotJPEG(char *filename, int compression, qbyte *screendata, int screenwidth, int screenheight);
|
||||
#endif
|
||||
#ifdef AVAIL_PNGLIB
|
||||
int Image_WritePNG (char *filename, int compression, qbyte *pixels, int width, int height);
|
||||
|
@ -1690,6 +1691,7 @@ void SCR_ScreenShot (char *filename)
|
|||
int truewidth, trueheight;
|
||||
qbyte *buffer;
|
||||
int i, c, temp;
|
||||
extern cvar_t scr_sshot_compression;
|
||||
|
||||
#define MAX_PREPAD 128
|
||||
char *ext;
|
||||
|
@ -1701,14 +1703,14 @@ void SCR_ScreenShot (char *filename)
|
|||
#ifdef AVAIL_PNGLIB
|
||||
if (!strcmp(ext, "png"))
|
||||
{
|
||||
Image_WritePNG(filename, 100, buffer+MAX_PREPAD, truewidth, trueheight);
|
||||
Image_WritePNG(filename, scr_sshot_compression.value, buffer+MAX_PREPAD, truewidth, trueheight);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef AVAIL_JPEGLIB
|
||||
if (!strcmp(ext, "jpeg") || !strcmp(ext, "jpg"))
|
||||
{
|
||||
screenshotJPEG(filename, buffer+MAX_PREPAD, truewidth, trueheight);
|
||||
screenshotJPEG(filename, scr_sshot_compression.value, buffer+MAX_PREPAD, truewidth, trueheight);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
|
|
@ -713,7 +713,8 @@ int Image_WritePNG (char *filename, int compression, qbyte *pixels, int width, i
|
|||
}
|
||||
|
||||
png_init_io(png_ptr, fp);
|
||||
png_set_compression_level(png_ptr, (compression*Z_BEST_COMPRESSION)/100);
|
||||
compression = bound(0, compression, 100);
|
||||
png_set_compression_level(png_ptr, Z_NO_COMPRESSION + (compression*(Z_BEST_COMPRESSION-Z_NO_COMPRESSION))/100);
|
||||
|
||||
png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
|
||||
png_write_info(png_ptr, info_ptr);
|
||||
|
@ -1050,7 +1051,7 @@ void jpeg_mem_dest (j_compress_ptr cinfo, vfsfile_t *vfs)
|
|||
METHODDEF(void) jpeg_error_exit (j_common_ptr cinfo) {
|
||||
longjmp(((jpeg_error_mgr_wrapper *) cinfo->err)->setjmp_buffer, 1);
|
||||
}
|
||||
void screenshotJPEG(char *filename, qbyte *screendata, int screenwidth, int screenheight) //input is rgb NOT rgba
|
||||
void screenshotJPEG(char *filename, int compression, qbyte *screendata, int screenwidth, int screenheight) //input is rgb NOT rgba
|
||||
{
|
||||
qbyte *buffer;
|
||||
vfsfile_t *outfile;
|
||||
|
@ -1088,7 +1089,7 @@ void screenshotJPEG(char *filename, qbyte *screendata, int screenwidth, int scre
|
|||
cinfo.input_components = 3;
|
||||
cinfo.in_color_space = JCS_RGB;
|
||||
jpeg_set_defaults(&cinfo);
|
||||
jpeg_set_quality (&cinfo, 75/*bound(0, (int) gl_image_jpeg_quality_level.value, 100)*/, true);
|
||||
jpeg_set_quality (&cinfo, bound(0, compression, 100), true);
|
||||
jpeg_start_compress(&cinfo, true);
|
||||
|
||||
while (cinfo.next_scanline < cinfo.image_height)
|
||||
|
|
|
@ -171,7 +171,7 @@ cvar_t gl_lateswap = SCVAR("gl_lateswap", "0");
|
|||
cvar_t gl_mylumassuck = SCVAR("gl_mylumassuck", "0");
|
||||
|
||||
cvar_t scr_sshot_type = SCVAR("scr_sshot_type", "jpg");
|
||||
|
||||
cvar_t scr_sshot_compression = SCVAR("scr_sshot_compression", "75");
|
||||
|
||||
cvar_t scr_centersbar = SCVAR("scr_centersbar", "0");
|
||||
cvar_t scr_consize = SCVAR("scr_consize", "0.5");
|
||||
|
@ -522,6 +522,7 @@ void Renderer_Init(void)
|
|||
Cvar_Register(&scr_chatmodecvar, SCREENOPTIONS);
|
||||
|
||||
Cvar_Register (&scr_sshot_type, SCREENOPTIONS);
|
||||
Cvar_Register (&scr_sshot_compression, SCREENOPTIONS);
|
||||
|
||||
Cvar_Register(&cl_cursor, SCREENOPTIONS);
|
||||
Cvar_Register(&cl_cursorsize, SCREENOPTIONS);
|
||||
|
|
Loading…
Reference in a new issue