From 3acf5f0cba50f43e1720eed26990a84e8b0b9d43 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Thu, 15 Feb 2018 00:39:43 +0100 Subject: [PATCH] VID_WriteScreenshot() PNG compression level must be < 10 10 is no valid zlib compression level, so make sure it's not used Thanks to @maraakate for pointing this out! --- src/backends/generic/vid.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backends/generic/vid.c b/src/backends/generic/vid.c index 21c04df9..52a95e6c 100644 --- a/src/backends/generic/vid.c +++ b/src/backends/generic/vid.c @@ -261,7 +261,7 @@ void VID_WriteScreenshot( int width, int height, int comp, const void* data ) if(q[i] < '0' || q[i] > '9') { Com_Printf("the (optional!) third argument to 'screenshot' is jpg quality, a number between 1 and 100\n"); - Com_Printf(" or png compression level, between 0 and 10!\n"); + Com_Printf(" or png compression level, between 0 and 9!\n"); return; } } @@ -269,7 +269,7 @@ void VID_WriteScreenshot( int width, int height, int comp, const void* data ) if(format == 2) // png { if(quality < 0) quality = 0; - else if(quality > 10) quality = 10; + else if(quality > 9) quality = 9; } else if(format == 3) // jpg { @@ -306,7 +306,7 @@ void VID_WriteScreenshot( int width, int height, int comp, const void* data ) case 0: success = stbi_write_tga(checkname, width, height, comp, data); break; case 1: success = stbi_write_bmp(checkname, width, height, comp, data); break; case 2: - stbi_write_png_compression_level = (quality <= 10) ? quality : 7; + stbi_write_png_compression_level = (quality < 10) ? quality : 7; success = stbi_write_png(checkname, width, height, comp, data, 0); break; case 3: success = stbi_write_jpg(checkname, width, height, comp, data, quality); break;