mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-15 08:53:53 +08:00
fix
This commit is contained in:
parent
09c0ffc54b
commit
15e5315e83
@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
#ifndef WINXP
|
||||||
#include <winrt/Windows.Foundation.h>
|
#include <winrt/Windows.Foundation.h>
|
||||||
#include <winrt/Windows.Storage.Pickers.h>
|
#include <winrt/Windows.Storage.Pickers.h>
|
||||||
#include <winrt/Windows.Storage.Streams.h>
|
#include <winrt/Windows.Storage.Streams.h>
|
||||||
@ -25,8 +27,10 @@ using namespace Windows::Media::Devices;
|
|||||||
using namespace Windows::Security::Cryptography;
|
using namespace Windows::Security::Cryptography;
|
||||||
using namespace Windows::Globalization;
|
using namespace Windows::Globalization;
|
||||||
using namespace Windows::Foundation::Collections;
|
using namespace Windows::Foundation::Collections;
|
||||||
|
#endif
|
||||||
DECLARE_API bool check_language_valid(wchar_t *language)
|
DECLARE_API bool check_language_valid(wchar_t *language)
|
||||||
{
|
{
|
||||||
|
#ifndef WINXP
|
||||||
OcrEngine ocrEngine = OcrEngine::TryCreateFromUserProfileLanguages();
|
OcrEngine ocrEngine = OcrEngine::TryCreateFromUserProfileLanguages();
|
||||||
std::wstring l = language;
|
std::wstring l = language;
|
||||||
try
|
try
|
||||||
@ -38,9 +42,13 @@ DECLARE_API bool check_language_valid(wchar_t *language)
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
DECLARE_API void getlanguagelist(void (*cb)(LPCWSTR))
|
DECLARE_API void getlanguagelist(void (*cb)(LPCWSTR))
|
||||||
{
|
{
|
||||||
|
#ifndef WINXP
|
||||||
OcrEngine ocrEngine = OcrEngine::TryCreateFromUserProfileLanguages();
|
OcrEngine ocrEngine = OcrEngine::TryCreateFromUserProfileLanguages();
|
||||||
auto languages = ocrEngine.AvailableRecognizerLanguages();
|
auto languages = ocrEngine.AvailableRecognizerLanguages();
|
||||||
|
|
||||||
@ -49,9 +57,11 @@ DECLARE_API void getlanguagelist(void(*cb)(LPCWSTR))
|
|||||||
auto lang = language.LanguageTag();
|
auto lang = language.LanguageTag();
|
||||||
cb(lang.c_str());
|
cb(lang.c_str());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
DECLARE_API void OCR(void *ptr, size_t size, wchar_t *lang, wchar_t *space, void (*cb)(int, int, int, int, LPCWSTR))
|
DECLARE_API void OCR(void *ptr, size_t size, wchar_t *lang, wchar_t *space, void (*cb)(int, int, int, int, LPCWSTR))
|
||||||
{
|
{
|
||||||
|
#ifndef WINXP
|
||||||
IBuffer buffer = CryptographicBuffer::CreateFromByteArray(
|
IBuffer buffer = CryptographicBuffer::CreateFromByteArray(
|
||||||
winrt::array_view<uint8_t>(static_cast<uint8_t *>(ptr), size));
|
winrt::array_view<uint8_t>(static_cast<uint8_t *>(ptr), size));
|
||||||
InMemoryRandomAccessStream memoryStream;
|
InMemoryRandomAccessStream memoryStream;
|
||||||
@ -84,5 +94,5 @@ DECLARE_API void OCR(void *ptr, size_t size, wchar_t *lang, wchar_t *space, void
|
|||||||
}
|
}
|
||||||
cb(x1, y1, x2, y2, xx.c_str());
|
cb(x1, y1, x2, y2, xx.c_str());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
#include <dxgi.h>
|
|
||||||
|
#ifndef WINXP
|
||||||
|
#include <dxgi.h>
|
||||||
#include <inspectable.h>
|
#include <inspectable.h>
|
||||||
#include <dxgi1_2.h>
|
#include <dxgi1_2.h>
|
||||||
#include <d3d11.h>
|
#include <d3d11.h>
|
||||||
@ -203,8 +205,10 @@ void capture_window(HWND window_handle, void (*cb)(byte *, size_t))
|
|||||||
memcpy(ptr, p_buf.get(), l_bmp_info.bmiHeader.biSizeImage);
|
memcpy(ptr, p_buf.get(), l_bmp_info.bmiHeader.biSizeImage);
|
||||||
cb(p_buf2.get(), bmfh.bfSize);
|
cb(p_buf2.get(), bmfh.bfSize);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
DECLARE_API void winrt_capture_window(HWND hwnd, void (*cb)(byte *, size_t))
|
DECLARE_API void winrt_capture_window(HWND hwnd, void (*cb)(byte *, size_t))
|
||||||
{
|
{
|
||||||
|
#ifndef WINXP
|
||||||
// auto hwnd = GetForegroundWindow();// FindWindow(L"Window_Magpie_967EB565-6F73-4E94-AE53-00CC42592A22", 0);
|
// auto hwnd = GetForegroundWindow();// FindWindow(L"Window_Magpie_967EB565-6F73-4E94-AE53-00CC42592A22", 0);
|
||||||
auto style_ex = GetWindowLong(hwnd, GWL_EXSTYLE);
|
auto style_ex = GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||||
auto style_ex_save = style_ex;
|
auto style_ex_save = style_ex;
|
||||||
@ -220,4 +224,5 @@ DECLARE_API void winrt_capture_window(HWND hwnd, void (*cb)(byte *, size_t))
|
|||||||
capture_window(hwnd, cb);
|
capture_window(hwnd, cb);
|
||||||
if (needset)
|
if (needset)
|
||||||
SetWindowLong(hwnd, GWL_EXSTYLE, style_ex_save);
|
SetWindowLong(hwnd, GWL_EXSTYLE, style_ex_save);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user