aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Martinez <kaeza@users.sf.net>2016-03-07 19:09:07 -0300
committerShadowNinja <shadowninja@minetest.net>2016-03-12 17:12:43 -0500
commit2c72f6da7b7595d2e180937f05f902c510ef1c14 (patch)
treed35836c6f3b45fc33eb978d66b77c9f10a2aa335
parent37b4f0d34c73de58e0f5d153b7e699dc7430e23d (diff)
downloadminetest-2c72f6da7b7595d2e180937f05f902c510ef1c14.tar.gz
minetest-2c72f6da7b7595d2e180937f05f902c510ef1c14.tar.bz2
minetest-2c72f6da7b7595d2e180937f05f902c510ef1c14.zip
Add options for screenshot format and quality
-rw-r--r--builtin/settingtypes.txt8
-rw-r--r--minetest.conf.example10
-rw-r--r--src/client.cpp7
-rw-r--r--src/defaultsettings.cpp2
-rw-r--r--src/settings_translation_file.cpp4
5 files changed, 29 insertions, 2 deletions
diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt
index 1672e08ca..c1157b163 100644
--- a/builtin/settingtypes.txt
+++ b/builtin/settingtypes.txt
@@ -554,6 +554,14 @@ fallback_font_shadow_alpha (Fallback font shadow alpha) int 128 0 255
# Path to save screenshots at.
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]
# Adjust dpi configuration to your screen (non X11/Android only) e.g. for 4k screens.
diff --git a/minetest.conf.example b/minetest.conf.example
index 1587cba76..cd0be5296 100644
--- a/minetest.conf.example
+++ b/minetest.conf.example
@@ -653,6 +653,16 @@
# type: 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
# Adjust dpi configuration to your screen (non X11/Android only) e.g. for 4k screens.
diff --git a/src/client.cpp b/src/client.cpp
index f27f031c5..e13344ec2 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1813,9 +1813,12 @@ void Client::makeScreenshot(IrrlichtDevice *device)
+ DIR_DELIM
+ std::string("screenshot_")
+ std::string(timetstamp_c);
- std::string filename_ext = ".png";
+ std::string filename_ext = "." + g_settings->get("screenshot_format");
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
unsigned serial = 0;
@@ -1837,7 +1840,7 @@ void Client::makeScreenshot(IrrlichtDevice *device)
raw_image->copyTo(image);
std::ostringstream sstr;
- if (driver->writeImageToFile(image, filename.c_str())) {
+ if (driver->writeImageToFile(image, filename.c_str(), quality)) {
sstr << "Saved screenshot to '" << filename << "'";
} else {
sstr << "Failed to save screenshot '" << filename << "'";
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index db2950fc2..53059e8ad 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -123,6 +123,8 @@ void set_default_settings(Settings *settings)
settings->setDefault("invert_mouse", "false");
settings->setDefault("enable_clouds", "true");
settings->setDefault("screenshot_path", ".");
+ settings->setDefault("screenshot_format", "png");
+ settings->setDefault("screenshot_quality", "0");
settings->setDefault("view_bobbing_amount", "1.0");
settings->setDefault("fall_bobbing_amount", "0.0");
settings->setDefault("enable_3d_clouds", "true");
diff --git a/src/settings_translation_file.cpp b/src/settings_translation_file.cpp
index e92a34cba..f115bc011 100644
--- a/src/settings_translation_file.cpp
+++ b/src/settings_translation_file.cpp
@@ -272,6 +272,10 @@ fake_function() {
gettext("Fallback font shadow alpha");
gettext("Screenshot folder");
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("DPI");
gettext("Adjust dpi configuration to your screen (non X11/Android only) e.g. for 4k screens.");