
25.07.2021, 17:46
|
|
Постоянный
Регистрация: 26.03.2016
Сообщений: 660
С нами:
5332594
Репутация:
163
|
|
гораздо быстрее будет делать скриншот с помощью GDI++:
C++:
Код:
// ConsoleApplication10.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include
#include
#include
#pragma comment(lib, "GdiPlus.lib")
using
namespace
Gdiplus
;
static
const
GUID png
=
{
0x557cf406
,
0x1a04
,
0x11d3
,
{
0x9a
,
0x73
,
0x00
,
0x00
,
0xf8
,
0x1e
,
0xf3
,
0x2e
}
}
;
int
main
(
void
)
{
GdiplusStartupInput gdiplusStartupInput
;
ULONG_PTR gdiplusToken
;
GdiplusStartup
(
&
gdiplusToken
,
&
gdiplusStartupInput
,
NULL
)
;
HDC window_dc
,
memdc
;
HBITMAP membit
;
// Получаем DC окна по его HWND
HWND window_handle
=
FindWindowA
(
0
,
"GTA SA:MP"
)
;
window_dc
=
GetDC
(
window_handle
)
;
// Определяем разрешение экрана
int
Height
,
Width
;
Height
=
GetSystemMetrics
(
SM_CYSCREEN
)
;
Width
=
GetSystemMetrics
(
SM_CXSCREEN
)
;
// Создаем новый DC, идентичный десктоповскому и битмап размером с экран.
memdc
=
CreateCompatibleDC
(
window_dc
)
;
membit
=
CreateCompatibleBitmap
(
window_dc
,
Width
,
Height
)
;
SelectObject
(
memdc
,
membit
)
;
// Улыбаемся... Снято!
BitBlt
(
memdc
,
0
,
0
,
Width
,
Height
,
window_dc
,
0
,
0
,
SRCCOPY
)
;
HBITMAP hBitmap
;
hBitmap
=
(
HBITMAP
)
SelectObject
(
memdc
,
membit
)
;
Gdiplus
::
Bitmap
bitmap
(
hBitmap
,
NULL
)
;
bitmap
.
Save
(
L
"screen.png"
,
&
png
)
;
DeleteObject
(
hBitmap
)
;
return
0
;
}
Скриншот с GDI+ - C++ WinAPI - Киберфорум
Скриншот с GDI+ C++ WinAPI Решение и ответ на вопрос 1526421
www.cyberforum.ru
Capturing an Image - Win32 apps
You can use a bitmap to capture an image, and you can store the captured image in memory, display it at a different location in your application's window, or display it in another window.
docs.microsoft.com
|
|
|