Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Move screenshot code into it's own file. Move surface capturing code in... #1511

Merged
merged 1 commit into from

2 participants

@hydra

...to it's own class so it can be reused. Add message to Util.cpp as it appears to be a big dumping ground for disparate code.

Re-created pull-request. Previous one was from the wrong branch.

@jmarshallnz
Owner

Looks good. Needs build support on Linux (simply add to the Makefile) and OSX (trickier - one of the devs here will take care of it once it goes in).

@hydra

Can you do the makefile as part of the merge; I don't have a linux build environment setup here yet. I'll be adding AmbiPi support (which was the driver for this refactor) to OSX and Linux so will setup OSX and Linux build environments in due couse but not ready yet.

ok?

xbmc/Screenshot.h
((7 lines not shown))
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+class CScreenshotSurface {
+
@jmarshallnz Owner

Please put the brackets on separate lines. Also, you need at least #include "utils/StdString.h" here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
xbmc/Screenshot.h
((15 lines not shown))
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+class CScreenshotSurface {
+
+public:
+ int m_width;
+ int m_height;
+ int m_stride;
+ unsigned char* m_buffer;
+
+ CScreenshotSurface(void);
+ boolean capture( void );
@jmarshallnz Owner

This should be bool, not boolean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
xbmc/Screenshot.cpp
((39 lines not shown))
+#include "utils/JobManager.h"
+#include "utils/URIUtils.h"
+#include "utils/log.h"
+
+using namespace std;
+using namespace XFILE;
+
+CScreenshotSurface::CScreenshotSurface()
+{
+ m_width = 0;
+ m_height = 0;
+ m_stride = 0;
+ m_buffer = NULL;
+}
+
+boolean CScreenshotSurface::capture()
@jmarshallnz Owner

bool, not boolean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jmarshallnz
Owner

Once those last ones are fixed, if you squash down the fixes, I'll merge and fix up the OSX and Makefile builds.

@jmarshallnz jmarshallnz was assigned
@hydra

Addressed two comments from yesterday and squashed commits (you did mean 'git reset'..., 'git commit', 'git push origin relocate-screenshot-code2 --force' right?)

I wanted to keep my first pull request simple so I could figure out the process and start communication. I'm sure i'll be making additional pull requests in the future to help out when I get time.

Thanks again!

@hydra

Also, once this is done let me know so I can make a pull request for this branch:

https://github.com/hydra/xbmc/commits/refactor-screenshot-code1

@jmarshallnz
Owner

There's two commits here still. You need to squash them together down into one commit (via an interactive rebase or similar) then force push back so there's a single commit.

@hydra

Sure, i'll do that tomorrow.

@hydra

Done

@hydra

Also added missing #prama once

@jmarshallnz
Owner

Looks good - thanks!

@jmarshallnz jmarshallnz merged commit 00545ea into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 4, 2012
  1. @hydra

    Move screenshot code into it's own file. Move surface capturing code

    hydra authored
    into it's own class so it can be reused.
This page is out of date. Refresh to see the latest.
View
2  project/VS2010Express/XBMC.vcxproj
@@ -1198,6 +1198,7 @@
<ClCompile Include="..\..\xbmc\ThumbnailCache.cpp" />
<ClCompile Include="..\..\xbmc\URL.cpp" />
<ClCompile Include="..\..\xbmc\Util.cpp" />
+ <ClCompile Include="..\..\xbmc\Screenshot.cpp" />
<ClCompile Include="..\..\xbmc\utils\AlarmClock.cpp" />
<ClCompile Include="..\..\xbmc\utils\AliasShortcutUtils.cpp" />
<ClCompile Include="..\..\xbmc\utils\Archive.cpp" />
@@ -2355,6 +2356,7 @@
<ClInclude Include="..\..\xbmc\ThumbnailCache.h" />
<ClInclude Include="..\..\xbmc\URL.h" />
<ClInclude Include="..\..\xbmc\Util.h" />
+ <ClInclude Include="..\..\xbmc\Screenshot.h" />
<ClInclude Include="..\..\xbmc\utils\AlarmClock.h" />
<ClInclude Include="..\..\xbmc\utils\AliasShortcutUtils.h" />
<ClInclude Include="..\..\xbmc\utils\Archive.h" />
View
2  project/VS2010Express/XBMC.vcxproj.filters
@@ -2532,6 +2532,7 @@
<ClCompile Include="..\..\xbmc\PartyModeManager.cpp" />
<ClCompile Include="..\..\xbmc\PasswordManager.cpp" />
<ClCompile Include="..\..\xbmc\SectionLoader.cpp" />
+ <ClCompile Include="..\..\xbmc\Screenshot.cpp" />
<ClCompile Include="..\..\xbmc\Temperature.cpp" />
<ClCompile Include="..\..\xbmc\TextureCache.cpp" />
<ClCompile Include="..\..\xbmc\TextureCacheJob.cpp" />
@@ -5494,6 +5495,7 @@
<ClInclude Include="..\..\xbmc\NfoFile.h" />
<ClInclude Include="..\..\xbmc\PartyModeManager.h" />
<ClInclude Include="..\..\xbmc\PasswordManager.h" />
+ <ClInclude Include="..\..\xbmc\Screenshot.h" />
<ClInclude Include="..\..\xbmc\SortFileItem.h" />
<ClInclude Include="..\..\xbmc\SectionLoader.h" />
<ClInclude Include="..\..\xbmc\Temperature.h" />
View
3  xbmc/Application.cpp
@@ -25,6 +25,7 @@
#include "utils/Variant.h"
#include "utils/Splash.h"
#include "LangInfo.h"
+#include "Screenshot.h"
#include "Util.h"
#include "URL.h"
#include "guilib/TextureManager.h"
@@ -2658,7 +2659,7 @@ bool CApplication::OnAction(const CAction &action)
// screenshot : take a screenshot :)
if (action.GetID() == ACTION_TAKE_SCREENSHOT)
{
- CUtil::TakeScreenshot();
+ CScreenShot::TakeScreenshot();
return true;
}
// built in functions : execute the built-in
View
251 xbmc/Screenshot.cpp
@@ -0,0 +1,251 @@
+/*
+ * Copyright (C) 2005-2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "Screenshot.h"
+
+#include "system.h"
+#include <vector>
+
+#include "Util.h"
+
+#include "Application.h"
+#include "windowing/WindowingFactory.h"
+#include "pictures/Picture.h"
+
+#ifdef HAS_VIDEO_PLAYBACK
+#include "cores/VideoRenderers/RenderManager.h"
+#endif
+
+#include "filesystem/File.h"
+#include "guilib/GraphicContext.h"
+
+#include "utils/JobManager.h"
+#include "utils/URIUtils.h"
+#include "utils/log.h"
+
+using namespace std;
+using namespace XFILE;
+
+CScreenshotSurface::CScreenshotSurface()
+{
+ m_width = 0;
+ m_height = 0;
+ m_stride = 0;
+ m_buffer = NULL;
+}
+
+bool CScreenshotSurface::capture()
+{
+
+#ifdef HAS_DX
+ LPDIRECT3DSURFACE9 lpSurface = NULL, lpBackbuffer = NULL;
+ g_graphicsContext.Lock();
+ if (g_application.IsPlayingVideo())
+ {
+#ifdef HAS_VIDEO_PLAYBACK
+ g_renderManager.SetupScreenshot();
+#endif
+ }
+ g_application.RenderNoPresent();
+
+ if (FAILED(g_Windowing.Get3DDevice()->CreateOffscreenPlainSurface(g_Windowing.GetWidth(), g_Windowing.GetHeight(), D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &lpSurface, NULL)))
+ return false;
+
+ if (FAILED(g_Windowing.Get3DDevice()->GetRenderTarget(0, &lpBackbuffer)))
+ return false;
+
+ // now take screenshot
+ if (SUCCEEDED(g_Windowing.Get3DDevice()->GetRenderTargetData(lpBackbuffer, lpSurface)))
+ {
+ D3DLOCKED_RECT lr;
+ D3DSURFACE_DESC desc;
+ lpSurface->GetDesc(&desc);
+ if (SUCCEEDED(lpSurface->LockRect(&lr, NULL, D3DLOCK_READONLY)))
+ {
+ m_width = desc.Width;
+ m_height = desc.Height;
+ m_stride = lr.Pitch;
+ m_buffer = new unsigned char[m_height * m_stride];
+ memcpy(m_buffer, lr.pBits, m_height * m_stride);
+ lpSurface->UnlockRect();
+ }
+ else
+ {
+ CLog::Log(LOGERROR, "%s LockRect failed", __FUNCTION__);
+ }
+ }
+ else
+ {
+ CLog::Log(LOGERROR, "%s GetBackBuffer failed", __FUNCTION__);
+ }
+ lpSurface->Release();
+ lpBackbuffer->Release();
+
+ g_graphicsContext.Unlock();
+
+#elif defined(HAS_GL) || defined(HAS_GLES)
+
+ g_graphicsContext.BeginPaint();
+ if (g_application.IsPlayingVideo())
+ {
+#ifdef HAS_VIDEO_PLAYBACK
+ g_renderManager.SetupScreenshot();
+#endif
+ }
+ g_application.RenderNoPresent();
+#ifndef HAS_GLES
+ glReadBuffer(GL_BACK);
+#endif
+ //get current viewport
+ GLint viewport[4];
+ glGetIntegerv(GL_VIEWPORT, viewport);
+
+ m_width = viewport[2] - viewport[0];
+ m_height = viewport[3] - viewport[1];
+ m_stride = m_width * 4;
+ unsigned char* surface = new unsigned char[m_stride * m_height];
+
+ //read pixels from the backbuffer
+#if HAS_GLES == 2
+ glReadPixels(viewport[0], viewport[1], viewport[2], viewport[3], GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)surface);
+#else
+ glReadPixels(viewport[0], viewport[1], viewport[2], viewport[3], GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*)surface);
+#endif
+ g_graphicsContext.EndPaint();
+
+ //make a new buffer and copy the read image to it with the Y axis inverted
+ m_buffer = new unsigned char[m_stride * m_height];
+ for (int y = 0; y < m_height; y++)
+ {
+#ifdef HAS_GLES
+ // we need to save in BGRA order so XOR Swap RGBA -> BGRA
+ unsigned char* swap_pixels = surface + (m_height - y - 1) * m_stride;
+ for (int x = 0; x < width; x++, swap_pixels+=4)
+ {
+ std::swap(swap_pixels[0], swap_pixels[2]);
+ }
+#endif
+ memcpy(m_buffer + y * m_stride, surface + (m_height - y - 1) *m_ stride, m_stride);
+ }
+
+ delete [] surface;
+
+#else
+ //nothing to take a screenshot from
+ return false;
+#endif
+
+ return true;
+}
+
+void CScreenShot::TakeScreenshot(const CStdString &filename, bool sync)
+{
+
+ CScreenshotSurface surface;
+ if (!surface.capture())
+ {
+ CLog::Log(LOGERROR, "Screenshot %s failed", filename.c_str());
+ return;
+ }
+
+ CLog::Log(LOGDEBUG, "Saving screenshot %s", filename.c_str());
+
+ //set alpha byte to 0xFF
+ for (int y = 0; y < surface.m_height; y++)
+ {
+ unsigned char* alphaptr = surface.m_buffer - 1 + y * surface.m_stride;
+ for (int x = 0; x < surface.m_width; x++)
+ *(alphaptr += 4) = 0xFF;
+ }
+
+ //if sync is true, the png file needs to be completely written when this function returns
+ if (sync)
+ {
+ if (!CPicture::CreateThumbnailFromSurface(surface.m_buffer, surface.m_width, surface.m_height, surface.m_stride, filename))
+ CLog::Log(LOGERROR, "Unable to write screenshot %s", filename.c_str());
+
+ delete [] surface.m_buffer;
+ }
+ else
+ {
+ //make sure the file exists to avoid concurrency issues
+ FILE* fp = fopen(filename.c_str(), "w");
+ if (fp)
+ fclose(fp);
+ else
+ CLog::Log(LOGERROR, "Unable to create file %s", filename.c_str());
+
+ //write .png file asynchronous with CThumbnailWriter, prevents stalling of the render thread
+ //buffer is deleted from CThumbnailWriter
+ CThumbnailWriter* thumbnailwriter = new CThumbnailWriter(surface.m_buffer, surface.m_width, surface.m_height, surface.m_stride, filename);
+ CJobManager::GetInstance().AddJob(thumbnailwriter, NULL);
+ }
+}
+
+void CScreenShot::TakeScreenshot()
+{
+ static bool savingScreenshots = false;
+ static vector<CStdString> screenShots;
+
+ bool promptUser = false;
+ // check to see if we have a screenshot folder yet
+ CStdString strDir = g_guiSettings.GetString("debug.screenshotpath", false);
+ if (strDir.IsEmpty())
+ {
+ strDir = "special://temp/";
+ if (!savingScreenshots)
+ {
+ promptUser = true;
+ savingScreenshots = true;
+ screenShots.clear();
+ }
+ }
+ URIUtils::RemoveSlashAtEnd(strDir);
+
+ if (!strDir.IsEmpty())
+ {
+ CStdString file = CUtil::GetNextFilename(URIUtils::AddFileToFolder(strDir, "screenshot%03d.png"), 999);
+
+ if (!file.IsEmpty())
+ {
+ TakeScreenshot(file, false);
+ if (savingScreenshots)
+ screenShots.push_back(file);
+ if (promptUser)
+ { // grab the real directory
+ CStdString newDir = g_guiSettings.GetString("debug.screenshotpath");
+ if (!newDir.IsEmpty())
+ {
+ for (unsigned int i = 0; i < screenShots.size(); i++)
+ {
+ CStdString file = CUtil::GetNextFilename(URIUtils::AddFileToFolder(newDir, "screenshot%03d.png"), 999);
+ CFile::Cache(screenShots[i], file);
+ }
+ screenShots.clear();
+ }
+ savingScreenshots = false;
+ }
+ }
+ else
+ {
+ CLog::Log(LOGWARNING, "Too many screen shots or invalid folder");
+ }
+ }
+}
View
43 xbmc/Screenshot.h
@@ -0,0 +1,43 @@
+#pragma once
+/*
+ * Copyright (C) 2005-2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "utils/StdString.h"
+
+class CScreenshotSurface
+{
+
+public:
+ int m_width;
+ int m_height;
+ int m_stride;
+ unsigned char* m_buffer;
+
+ CScreenshotSurface(void);
+ bool capture( void );
+};
+
+class CScreenShot
+{
+
+public:
+ static void TakeScreenshot();
+ static void TakeScreenshot(const CStdString &filename, bool sync);
+};
View
205 xbmc/Util.cpp
@@ -56,9 +56,6 @@
#ifdef HAS_UPNP
#include "filesystem/UPnPDirectory.h"
#endif
-#ifdef HAS_VIDEO_PLAYBACK
-#include "cores/VideoRenderers/RenderManager.h"
-#endif
#include "utils/RegExp.h"
#include "settings/GUISettings.h"
#include "guilib/TextureManager.h"
@@ -84,18 +81,16 @@
#include "utils/TimeUtils.h"
#include "utils/URIUtils.h"
#include "utils/log.h"
-#include "pictures/Picture.h"
-#include "utils/JobManager.h"
+
#include "cores/dvdplayer/DVDSubtitles/DVDSubtitleTagSami.h"
#include "cores/dvdplayer/DVDSubtitles/DVDSubtitleStream.h"
-#include "windowing/WindowingFactory.h"
#include "URL.h"
#ifdef HAVE_LIBCAP
#include <sys/capability.h>
#endif
using namespace std;
-using namespace XFILE;
+
#define clamp(x) (x) > 255.f ? 255 : ((x) < 0 ? 0 : (BYTE)(x+0.5f)) // Valid ranges: brightness[-1 -> 1 (0 is default)] contrast[0 -> 2 (1 is default)] gamma[0.5 -> 3.5 (1 is default)] default[ramp is linear]
static const int64_t SECS_BETWEEN_EPOCHS = 11644473600LL;
@@ -867,202 +862,6 @@ void CUtil::Tokenize(const CStdString& path, vector<CStdString>& tokens, const s
}
}
-void CUtil::TakeScreenshot(const CStdString &filename, bool sync)
-{
- int width;
- int height;
- int stride;
- unsigned char* outpixels = NULL;
-
-#ifdef HAS_DX
- LPDIRECT3DSURFACE9 lpSurface = NULL, lpBackbuffer = NULL;
- g_graphicsContext.Lock();
- if (g_application.IsPlayingVideo())
- {
-#ifdef HAS_VIDEO_PLAYBACK
- g_renderManager.SetupScreenshot();
-#endif
- }
- g_application.RenderNoPresent();
-
- if (FAILED(g_Windowing.Get3DDevice()->CreateOffscreenPlainSurface(g_Windowing.GetWidth(), g_Windowing.GetHeight(), D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &lpSurface, NULL)))
- return;
-
- if (FAILED(g_Windowing.Get3DDevice()->GetRenderTarget(0, &lpBackbuffer)))
- return;
-
- // now take screenshot
- if (SUCCEEDED(g_Windowing.Get3DDevice()->GetRenderTargetData(lpBackbuffer, lpSurface)))
- {
- D3DLOCKED_RECT lr;
- D3DSURFACE_DESC desc;
- lpSurface->GetDesc(&desc);
- if (SUCCEEDED(lpSurface->LockRect(&lr, NULL, D3DLOCK_READONLY)))
- {
- width = desc.Width;
- height = desc.Height;
- stride = lr.Pitch;
- outpixels = new unsigned char[height * stride];
- memcpy(outpixels, lr.pBits, height * stride);
- lpSurface->UnlockRect();
- }
- else
- {
- CLog::Log(LOGERROR, "%s LockRect failed", __FUNCTION__);
- }
- }
- else
- {
- CLog::Log(LOGERROR, "%s GetBackBuffer failed", __FUNCTION__);
- }
- lpSurface->Release();
- lpBackbuffer->Release();
-
- g_graphicsContext.Unlock();
-
-#elif defined(HAS_GL) || defined(HAS_GLES)
-
- g_graphicsContext.BeginPaint();
- if (g_application.IsPlayingVideo())
- {
-#ifdef HAS_VIDEO_PLAYBACK
- g_renderManager.SetupScreenshot();
-#endif
- }
- g_application.RenderNoPresent();
-#ifndef HAS_GLES
- glReadBuffer(GL_BACK);
-#endif
- //get current viewport
- GLint viewport[4];
- glGetIntegerv(GL_VIEWPORT, viewport);
-
- width = viewport[2] - viewport[0];
- height = viewport[3] - viewport[1];
- stride = width * 4;
- unsigned char* pixels = new unsigned char[stride * height];
-
- //read pixels from the backbuffer
-#if HAS_GLES == 2
- glReadPixels(viewport[0], viewport[1], viewport[2], viewport[3], GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)pixels);
-#else
- glReadPixels(viewport[0], viewport[1], viewport[2], viewport[3], GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*)pixels);
-#endif
- g_graphicsContext.EndPaint();
-
- //make a new buffer and copy the read image to it with the Y axis inverted
- outpixels = new unsigned char[stride * height];
- for (int y = 0; y < height; y++)
- {
-#ifdef HAS_GLES
- // we need to save in BGRA order so XOR Swap RGBA -> BGRA
- unsigned char* swap_pixels = pixels + (height - y - 1) * stride;
- for (int x = 0; x < width; x++, swap_pixels+=4)
- {
- std::swap(swap_pixels[0], swap_pixels[2]);
- }
-#endif
- memcpy(outpixels + y * stride, pixels + (height - y - 1) * stride, stride);
- }
-
- delete [] pixels;
-
-#else
- //nothing to take a screenshot from
- return;
-#endif
-
- if (!outpixels)
- {
- CLog::Log(LOGERROR, "Screenshot %s failed", filename.c_str());
- return;
- }
-
- CLog::Log(LOGDEBUG, "Saving screenshot %s", filename.c_str());
-
- //set alpha byte to 0xFF
- for (int y = 0; y < height; y++)
- {
- unsigned char* alphaptr = outpixels - 1 + y * stride;
- for (int x = 0; x < width; x++)
- *(alphaptr += 4) = 0xFF;
- }
-
- //if sync is true, the png file needs to be completely written when this function returns
- if (sync)
- {
- if (!CPicture::CreateThumbnailFromSurface(outpixels, width, height, stride, filename))
- CLog::Log(LOGERROR, "Unable to write screenshot %s", filename.c_str());
-
- delete [] outpixels;
- }
- else
- {
- //make sure the file exists to avoid concurrency issues
- FILE* fp = fopen(filename.c_str(), "w");
- if (fp)
- fclose(fp);
- else
- CLog::Log(LOGERROR, "Unable to create file %s", filename.c_str());
-
- //write .png file asynchronous with CThumbnailWriter, prevents stalling of the render thread
- //outpixels is deleted from CThumbnailWriter
- CThumbnailWriter* thumbnailwriter = new CThumbnailWriter(outpixels, width, height, stride, filename);
- CJobManager::GetInstance().AddJob(thumbnailwriter, NULL);
- }
-}
-
-void CUtil::TakeScreenshot()
-{
- static bool savingScreenshots = false;
- static vector<CStdString> screenShots;
-
- bool promptUser = false;
- // check to see if we have a screenshot folder yet
- CStdString strDir = g_guiSettings.GetString("debug.screenshotpath", false);
- if (strDir.IsEmpty())
- {
- strDir = "special://temp/";
- if (!savingScreenshots)
- {
- promptUser = true;
- savingScreenshots = true;
- screenShots.clear();
- }
- }
- URIUtils::RemoveSlashAtEnd(strDir);
-
- if (!strDir.IsEmpty())
- {
- CStdString file = CUtil::GetNextFilename(URIUtils::AddFileToFolder(strDir, "screenshot%03d.png"), 999);
-
- if (!file.IsEmpty())
- {
- TakeScreenshot(file, false);
- if (savingScreenshots)
- screenShots.push_back(file);
- if (promptUser)
- { // grab the real directory
- CStdString newDir = g_guiSettings.GetString("debug.screenshotpath");
- if (!newDir.IsEmpty())
- {
- for (unsigned int i = 0; i < screenShots.size(); i++)
- {
- CStdString file = CUtil::GetNextFilename(URIUtils::AddFileToFolder(newDir, "screenshot%03d.png"), 999);
- CFile::Cache(screenShots[i], file);
- }
- screenShots.clear();
- }
- savingScreenshots = false;
- }
- }
- else
- {
- CLog::Log(LOGWARNING, "Too many screen shots or invalid folder");
- }
- }
-}
-
void CUtil::StatToStatI64(struct _stati64 *result, struct stat *stat)
{
result->st_dev = stat->st_dev;
View
2  xbmc/Util.h
@@ -92,8 +92,6 @@ class CUtil
static int64_t ToInt64(uint32_t high, uint32_t low);
static CStdString GetNextFilename(const CStdString &fn_template, int max);
static CStdString GetNextPathname(const CStdString &path_template, int max);
- static void TakeScreenshot();
- static void TakeScreenshot(const CStdString &filename, bool sync);
static void Tokenize(const CStdString& path, std::vector<CStdString>& tokens, const std::string& delimiters);
static void StatToStatI64(struct _stati64 *result, struct stat *stat);
static void Stat64ToStatI64(struct _stati64 *result, struct __stat64 *stat);
View
3  xbmc/interfaces/Builtins.cpp
@@ -20,6 +20,7 @@
#include "system.h"
#include "utils/AlarmClock.h"
+#include "Screenshot.h"
#include "Application.h"
#include "ApplicationMessenger.h"
#include "Autorun.h"
@@ -323,7 +324,7 @@ int CBuiltins::Execute(const CStdString& execString)
}
else if (execute.Equals("takescreenshot"))
{
- CUtil::TakeScreenshot();
+ CScreenShot::TakeScreenshot();
}
else if (execute.Equals("activatewindow") || execute.Equals("replacewindow"))
{
View
3  xbmc/interfaces/http-api/XBMChttp.cpp
@@ -19,6 +19,7 @@
#include "playlists/PlayListFactory.h"
#include "Util.h"
+#include "Screenshot.h"
#include "PlayListPlayer.h"
#include "playlists/PlayList.h"
#include "filesystem/CurlFile.h"
@@ -2869,7 +2870,7 @@ int CXbmcHttp::xbmcTakeScreenshot(int numParas, CStdString paras[])
//filename can be blank
{
if (numParas<1)
- CUtil::TakeScreenshot();
+ CScreenShot::TakeScreenshot();
else
return SetResponse(openTag+"Error: xbmcTakeScreenshot with params depracated");
return SetResponse(openTag+"OK");
Something went wrong with that request. Please try again.