1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-06-30 08:24:05 +00:00

ScreenShot: move to common windows implementation

This commit is contained in:
Rosalie Wanders 2021-08-10 23:09:20 +02:00 committed by Sergey Lipskiy
parent 532eff450e
commit 70a9213d69
13 changed files with 20 additions and 51 deletions

View File

@ -398,6 +398,9 @@ copy /Y "$(OutDir)$(TargetName).*" "$(Mupen64PluginsDir_x64)")</Command>
<ClCompile Include="..\..\src\windows\ZilmarAPIImpl_windows.cpp">
<ExcludedFromBuild Condition="'$(Configuration)'=='Debug_mupenplus' Or '$(Configuration)'=='Release_mupenplus'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\windows\ScreenShot.cpp">
<ExcludedFromBuild Condition="'$(Configuration)'=='Debug_mupenplus' Or '$(Configuration)'=='Release_mupenplus'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ZilmarPluginAPI.cpp">
<ExcludedFromBuild Condition="'$(Configuration)'=='Debug_mupenplus' Or '$(Configuration)'=='Release_mupenplus'">true</ExcludedFromBuild>
</ClCompile>

View File

@ -145,6 +145,9 @@
</ClCompile>
<ClCompile Include="..\..\src\windows\ZilmarAPIImpl_windows.cpp">
<Filter>Source Files\windows</Filter>
</ClCompile>
<ClCompile Include="..\..\src\windows\ScreenShot.cpp">
<Filter>Source Files\windows</Filter>
</ClCompile>
<ClCompile Include="..\..\src\GLideNUI\Config_GLidenUI.cpp">
<Filter>Source Files\windows</Filter>

View File

@ -107,7 +107,6 @@
<ClCompile Include="..\..\src\GLideNUI-wtl\IniFileClass.cpp" />
<ClCompile Include="..\..\src\GLideNUI-wtl\InputDialog.cpp" />
<ClCompile Include="..\..\src\GLideNUI-wtl\Language.cpp" />
<ClCompile Include="..\..\src\GLideNUI-wtl\ScreenShot.cpp" />
<ClCompile Include="..\..\src\GLideNUI-wtl\Settings.cpp" />
<ClCompile Include="..\..\src\GLideNUI-wtl\util\StdString.cpp" />
<ClCompile Include="..\..\src\GLideNUI-wtl\util\util.cpp" />

View File

@ -66,9 +66,6 @@
<ClCompile Include="..\..\src\GLideNUI-wtl\IniFileClass.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\GLideNUI-wtl\ScreenShot.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\GLideNUI-wtl\Settings.cpp">
<Filter>Source Files</Filter>
</ClCompile>

View File

@ -127,7 +127,6 @@
<ClCompile Include="Release\moc_ConfigDialog.cpp">
<ExcludedFromBuild Condition="'$(Configuration)'=='Debug'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\GLideNUI\ScreenShot.cpp" />
<ClCompile Include="..\..\src\GLideNUI\Settings.cpp" />
</ItemGroup>
<ItemGroup>

View File

@ -69,9 +69,6 @@
<ClCompile Include="..\..\src\GLideNUI\GLideNUI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\GLideNUI\ScreenShot.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\GLideNUI\Settings.cpp">
<Filter>Source Files</Filter>
</ClCompile>

View File

@ -128,7 +128,6 @@ set(GLideNUI_SOURCES
GLideNUI/ConfigDialog.cpp
GLideNUI/Config_GLideNUI.cpp
GLideNUI/GLideNUI.cpp
GLideNUI/ScreenShot.cpp
GLideNUI/Settings.cpp
GLideNUI/QtKeyToHID.cpp
GLideNUI/HIDKeyToName.cpp
@ -223,6 +222,7 @@ else(MUPENPLUSAPI)
windows/GLideN64_windows.cpp
windows/MemoryStatus_windows.cpp
windows/ZilmarAPIImpl_windows.cpp
windows/ScreenShot.cpp
Graphics/OpenGLContext/windows/windows_DisplayWindow.cpp
Graphics/OpenGLContext/windows/WindowsWGL.cpp
${GLideNUI_SOURCES}

View File

@ -19,7 +19,6 @@ EXPORT bool CALL RunConfig(const wchar_t * _strFileName, const char * _romName,
EXPORT int CALL RunAbout(const wchar_t * _strFileName);
EXPORT void CALL LoadConfig(const wchar_t * _strFileName);
EXPORT void CALL LoadCustomRomSettings(const wchar_t * _strFileName, const char * _romName);
EXPORT void CALL SaveScreenshot(const wchar_t * _folder, const char * _name, int _width, int _height, const unsigned char * _data);
#if defined(__cplusplus)
}

View File

@ -19,7 +19,6 @@ EXPORT bool CALL RunConfig(const wchar_t * _strFileName, const char * _romName,
EXPORT int CALL RunAbout(const wchar_t * _strFileName);
EXPORT void CALL LoadConfig(const wchar_t * _strFileName);
EXPORT void CALL LoadCustomRomSettings(const wchar_t * _strFileName, const char * _romName);
EXPORT void CALL SaveScreenshot(const wchar_t * _folder, const char * _name, int _width, int _height, const unsigned char * _data);
#if defined(__cplusplus)
}

View File

@ -1,35 +0,0 @@
#include <QDir>
#include <QFile>
#include <QImage>
#include <QImageWriter>
#include "GLideNUI.h"
#include "../Config.h"
EXPORT void CALL SaveScreenshot(const wchar_t * _folder, const char * _name, int _width, int _height, const unsigned char * _data)
{
const char * png = "png";
const char * jpg = "jpg";
const char * fileExt = config.texture.screenShotFormat == 0 ? png : jpg;
QString folderName = QString::fromWCharArray(_folder);
QDir folder;
if (!folder.exists(folderName) && !folder.mkpath(folderName))
return;
QString romName(_name);
romName = romName.replace(' ', '_');
romName = romName.replace(':', ';');
QString fileName;
int i;
for (i = 0; i < 1000; ++i) {
fileName = fileName.asprintf("%lsGLideN64_%ls_%03i.%s", folderName.data(), romName.data(), i, fileExt);
QFile f(fileName);
if (!f.exists())
break;
}
if (i == 1000)
return;
QImage image(_data, _width, _height, QImage::Format_RGB888);
QImageWriter writer(fileName, fileExt);
writer.write(image.mirrored());
}

View File

@ -8,6 +8,7 @@
#include <Graphics/Context.h>
#include <Graphics/Parameters.h>
#include <DisplayWindow.h>
#include <windows/ScreenShot.h>
#include <Graphics/OpenGLContext/ThreadedOpenGl/opengl_Wrapper.h>
using namespace opengl;

View File

@ -1,7 +1,6 @@
#include "GLideNUI.h"
#include "../Config.h"
#include "util/util.h"
#include <Windows.h>
#include "Config.h"
#include "../GLideNHQ/inc/png.h"
void write_png_file(const wchar_t * file_name, int width, int height, const uint8_t *buffer)
@ -77,7 +76,7 @@ void write_png_file(const wchar_t * file_name, int width, int height, const uint
fclose(fp);
}
EXPORT void CALL SaveScreenshot(const wchar_t * _folder, const char * _name, int _width, int _height, const unsigned char * _data)
void SaveScreenshot(const wchar_t * _folder, const char * _name, int _width, int _height, const unsigned char * _data)
{
const wchar_t * fileExt = L"png";
@ -96,7 +95,9 @@ EXPORT void CALL SaveScreenshot(const wchar_t * _folder, const char * _name, int
if ((FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
return;
std::wstring romName = ToUTF16(_name);
wchar_t wbuf[MAX_PATH];
mbstowcs(wbuf, _name, MAX_PATH);
std::wstring romName = std::wstring(wbuf);
for (size_t i = 0, n = romName.size(); i < n; i++) {
if (romName[i] == L' ') romName[i] = L'_';
if (romName[i] == L':') romName[i] = L';';

6
src/windows/ScreenShot.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef SCREENSHOT_H
#define SCREENSHOT_H
void SaveScreenshot(const wchar_t * _folder, const char * _name, int _width, int _height, const unsigned char * _data);
#endif // SCREENSHOT_H