Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-08-24 18:52:10 +0000
committerStijn Buys <ingar@osirion.org>2008-08-24 18:52:10 +0000
commit9c4d134ab304794b755139e90ca6da9de73a1e9a (patch)
tree71373947f86aa5f72ea78fed695974cfb5117642 /src/client
parent184598a43548642b9a4bfe8c2fce58e4a966d0bb (diff)
JPEG screenshots
Diffstat (limited to 'src/client')
-rw-r--r--src/client/video.cc30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/client/video.cc b/src/client/video.cc
index 39e2c2a..ef1f82e 100644
--- a/src/client/video.cc
+++ b/src/client/video.cc
@@ -16,6 +16,7 @@
#include "render/render.h"
#include "render/tga.h"
#include "render/pngfile.h"
+#include "render/jpgfile.h"
#include "core/core.h"
#include "filesystem/filesystem.h"
#include "sys/sys.h"
@@ -48,6 +49,7 @@ core::Cvar *r_height;
core::Cvar *r_fullscreen;
core::Cvar *screenshotformat;
+core::Cvar *screenshotquality;
void restart()
{
@@ -86,8 +88,11 @@ bool init()
r_fullscreen = core::Cvar::get("r_fullscreen", "0", core::Cvar::Archive);
r_fullscreen->set_info("[bool] enable or disable fullscreen video");
- screenshotformat = core::Cvar::get("screenshotformat", "tga", core::Cvar::Archive);
- screenshotformat->set_info("[string] screenshot format: tga png");
+ screenshotformat = core::Cvar::get("screenshotformat", "jpg", core::Cvar::Archive);
+ screenshotformat->set_info("[string] screenshot format: jpg png tga");
+
+ screenshotquality = core::Cvar::get("screenshotquality", "85", core::Cvar::Archive);
+ screenshotquality->set_info("[int] screenshot jpg quality");
int bpp = 0;
int flags = 0;
@@ -217,6 +222,7 @@ void screenshot()
std::string filename;
const int TYPETGA = 0;
const int TYPEPNG = 1;
+ const int TYPEJPG = 2;
int filetype = TYPETGA;
// make sure the screenshots folder exists
@@ -226,20 +232,32 @@ void screenshot()
aux::lowercase(screenshotformat->str());
- if (screenshotformat->str().compare("png") == 0) {
+ if ((screenshotformat->str().compare("jpg") == 0) || (screenshotformat->str().compare("jpeg") == 0)) {
+ filetype = TYPEJPG;
+ if (screenshotquality->value() < 10) {
+ (*screenshotquality) = 10;
+ } else if (screenshotquality->value() > 100) {
+ (*screenshotquality) = 100;
+ }
+
+ } else if (screenshotformat->str().compare("png") == 0) {
filetype = TYPEPNG;
+
+ } else if (screenshotformat->str().compare("tga") == 0) {
+ filetype = TYPETGA;
+
} else {
filetype = TYPETGA;
(*screenshotformat) = "tga";
}
- // find the first available screenshotxxx.tga
+ // find the first available screenshotxxxx
do {
std::stringstream nstr;
nstr << screenshot_number;
shortname.assign(nstr.str());
- while(shortname.size() < 3)
+ while(shortname.size() < 4)
shortname.insert(0, 1, '0');
shortname.insert(0, "screenshots/osirion");
@@ -267,6 +285,8 @@ void screenshot()
if (filetype == TYPEPNG) {
render::PNG::save(filename.c_str(), image);
+ } else if (filetype == TYPEJPG) {
+ render::JPG::save(filename.c_str(), image, (int) screenshotquality->value());
} else if (filetype == TYPETGA) {
render::TGA::save(filename.c_str(), image);
}