From 36a90198e2586e8f7a3d29d48c5ca523affc12b8 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 11 Sep 2014 04:28:14 +0200 Subject: [PATCH] Add option to change screenshot image format --- apps/openmw/engine.cpp | 6 +++--- files/settings-default.cfg | 2 ++ libs/openengine/ogre/renderer.cpp | 4 ++-- libs/openengine/ogre/renderer.hpp | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index fa4c693375..1247ceda12 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -509,7 +509,7 @@ void OMW::Engine::screenshot() int shotCount = 0; const std::string& screenshotPath = mCfgMgr.getUserDataPath().string(); - + std::string format = Settings::Manager::getString("screenshot format", "General"); // Find the first unused filename with a do-while std::ostringstream stream; do @@ -518,11 +518,11 @@ void OMW::Engine::screenshot() stream.str(""); stream.clear(); - stream << screenshotPath << "screenshot" << std::setw(3) << std::setfill('0') << shotCount++ << ".png"; + stream << screenshotPath << "screenshot" << std::setw(3) << std::setfill('0') << shotCount++ << "." << format; } while (boost::filesystem::exists(stream.str())); - mOgre->screenshot(stream.str()); + mOgre->screenshot(stream.str(), format); } void OMW::Engine::setCompileAll (bool all) diff --git a/files/settings-default.cfg b/files/settings-default.cfg index ab9de47a4c..fc651f4632 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -60,6 +60,8 @@ num mipmaps = 8 shader mode = +screenshot format = png + [Shadows] # Shadows are only supported when object shaders are on! enabled = false diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index 78eff6aeed..fa98433acb 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -44,7 +44,7 @@ void OgreRenderer::update(float dt) { } -void OgreRenderer::screenshot(const std::string &file) +void OgreRenderer::screenshot(const std::string &file, const std::string& imageFormat) { /* Since Ogre uses narrow character interfaces, it does not support Unicode paths on Windows. Therefore we had to implement screenshot @@ -65,7 +65,7 @@ void OgreRenderer::screenshot(const std::string &file) ); mWindow->copyContentsToMemory(image.getPixelBox()); - Ogre::DataStreamPtr stream = image.encode("png"); + Ogre::DataStreamPtr stream = image.encode(imageFormat); Ogre::MemoryDataStream *mem = dynamic_cast(stream.get()); if (mem != 0) { // likely const char *ptr = reinterpret_cast(mem->getCurrentPtr()); diff --git a/libs/openengine/ogre/renderer.hpp b/libs/openengine/ogre/renderer.hpp index c7ec2ec449..5dba15b5a8 100644 --- a/libs/openengine/ogre/renderer.hpp +++ b/libs/openengine/ogre/renderer.hpp @@ -108,7 +108,7 @@ namespace OEngine void update(float dt); /// Write a screenshot to file - void screenshot(const std::string &file); + void screenshot(const std::string &file, const std::string& imageFormat); float getFPS();