Add options for screenshot format and quality

This commit is contained in:
Diego Martinez 2016-03-07 19:09:07 -03:00 committed by ShadowNinja
parent 37b4f0d34c
commit 2c72f6da7b
5 changed files with 29 additions and 2 deletions

@ -554,6 +554,14 @@ fallback_font_shadow_alpha (Fallback font shadow alpha) int 128 0 255
# Path to save screenshots at. # Path to save screenshots at.
screenshot_path (Screenshot folder) path screenshot_path (Screenshot folder) path
# Format of screenshots.
screenshot_format (Screenshot format) enum png png,jpg,bmp,pcx,ppm,tga
# Screenshot quality. Only used for JPEG format.
# 1 means worst quality; 100 means best quality.
# Use 0 for default quality.
screenshot_quality (Screenshot quality) int 0 0 100
[**Advanced] [**Advanced]
# Adjust dpi configuration to your screen (non X11/Android only) e.g. for 4k screens. # Adjust dpi configuration to your screen (non X11/Android only) e.g. for 4k screens.

@ -653,6 +653,16 @@
# type: path # type: path
# screenshot_path = # screenshot_path =
# Format of screenshots.
# type: enum values: png, jpg, bmp, pcx, ppm, tga
# screenshot_format = png
# Screenshot quality. Only used for JPEG format.
# 1 means worst quality; 100 means best quality.
# Use 0 for default quality.
# type: int min: 0 max: 100
# screenshot_quality = 0
### Advanced ### Advanced
# Adjust dpi configuration to your screen (non X11/Android only) e.g. for 4k screens. # Adjust dpi configuration to your screen (non X11/Android only) e.g. for 4k screens.

@ -1813,9 +1813,12 @@ void Client::makeScreenshot(IrrlichtDevice *device)
+ DIR_DELIM + DIR_DELIM
+ std::string("screenshot_") + std::string("screenshot_")
+ std::string(timetstamp_c); + std::string(timetstamp_c);
std::string filename_ext = ".png"; std::string filename_ext = "." + g_settings->get("screenshot_format");
std::string filename; std::string filename;
u32 quality = (u32)g_settings->getS32("screenshot_quality");
quality = MYMIN(MYMAX(quality, 0), 100) / 100.0 * 255;
// Try to find a unique filename // Try to find a unique filename
unsigned serial = 0; unsigned serial = 0;
@ -1837,7 +1840,7 @@ void Client::makeScreenshot(IrrlichtDevice *device)
raw_image->copyTo(image); raw_image->copyTo(image);
std::ostringstream sstr; std::ostringstream sstr;
if (driver->writeImageToFile(image, filename.c_str())) { if (driver->writeImageToFile(image, filename.c_str(), quality)) {
sstr << "Saved screenshot to '" << filename << "'"; sstr << "Saved screenshot to '" << filename << "'";
} else { } else {
sstr << "Failed to save screenshot '" << filename << "'"; sstr << "Failed to save screenshot '" << filename << "'";

@ -123,6 +123,8 @@ void set_default_settings(Settings *settings)
settings->setDefault("invert_mouse", "false"); settings->setDefault("invert_mouse", "false");
settings->setDefault("enable_clouds", "true"); settings->setDefault("enable_clouds", "true");
settings->setDefault("screenshot_path", "."); settings->setDefault("screenshot_path", ".");
settings->setDefault("screenshot_format", "png");
settings->setDefault("screenshot_quality", "0");
settings->setDefault("view_bobbing_amount", "1.0"); settings->setDefault("view_bobbing_amount", "1.0");
settings->setDefault("fall_bobbing_amount", "0.0"); settings->setDefault("fall_bobbing_amount", "0.0");
settings->setDefault("enable_3d_clouds", "true"); settings->setDefault("enable_3d_clouds", "true");

@ -272,6 +272,10 @@ fake_function() {
gettext("Fallback font shadow alpha"); gettext("Fallback font shadow alpha");
gettext("Screenshot folder"); gettext("Screenshot folder");
gettext("Path to save screenshots at."); gettext("Path to save screenshots at.");
gettext("Screenshot format");
gettext("Format of screenshots.");
gettext("Screenshot quality");
gettext("Screenshot quality. Only used for JPEG format.\n1 means worst quality; 100 means best quality.\nUse 0 for default quality.");
gettext("Advanced"); gettext("Advanced");
gettext("DPI"); gettext("DPI");
gettext("Adjust dpi configuration to your screen (non X11/Android only) e.g. for 4k screens."); gettext("Adjust dpi configuration to your screen (non X11/Android only) e.g. for 4k screens.");