Skip to content

Commit 1f8b79c

Browse files
authored
Merge pull request #1 from smasherprog/Dev
First Release of windows support
2 parents a9208a6 + 2a59141 commit 1f8b79c

36 files changed

+3494
-559
lines changed

.vscode/.cmaketools.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"variant": {
3+
"label": "Debug",
4+
"keywordSettings": {
5+
"buildType": "debug"
6+
},
7+
"description": "Emit debug information without performing optimizations"
8+
},
9+
"activeEnvironments": [
10+
"Visual C++ 14.0 - x86"
11+
]
12+
}

.vscode/c_cpp_properties.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Mac",
5+
"includePath": ["/usr/include"],
6+
"browse" : {
7+
"limitSymbolsToIncludedHeaders" : true,
8+
"databaseFilename" : ""
9+
}
10+
},
11+
{
12+
"name": "Linux",
13+
"includePath": ["/usr/include"],
14+
"browse" : {
15+
"limitSymbolsToIncludedHeaders" : true,
16+
"databaseFilename" : ""
17+
}
18+
},
19+
{
20+
"name": "Win32",
21+
"includePath": [
22+
"c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/",
23+
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.10586.0"
24+
],
25+
"browse" : {
26+
"limitSymbolsToIncludedHeaders" : true,
27+
"databaseFilename" : ""
28+
}
29+
}
30+
]
31+
}

.vscode/launch.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "C++ Launch (Windows)",
6+
"type": "cppvsdbg",
7+
"request": "launch",
8+
"program": "${workspaceRoot}/build/Example/Debug/Screen_Capture_Example.exe",
9+
"args": [],
10+
"stopAtEntry": false,
11+
"cwd": "${workspaceRoot}/build/Example/Debug/",
12+
"environment": [],
13+
"externalConsole": true
14+
}
15+
]
16+
}

.vscode/settings.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
"C_Cpp.clang_format_style": "WebKit",
4+
5+
}

.vscode/tasks.json

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"version": "0.1.0",
3+
"isShellCommand": true,
4+
"showOutput": "always",
5+
"suppressTaskName": true,
6+
"options": {
7+
"cwd": "${workspaceRoot}/build"
8+
},
9+
"echoCommand": true,
10+
"windows": {
11+
"command": "cmd",
12+
"args": ["/C"],
13+
"tasks": [
14+
{
15+
"taskName": "clean",
16+
"args": [ "rd /s /q", "${workspaceRoot}\\build"]
17+
},
18+
{
19+
"taskName": "cmake",
20+
"args": ["cmake", "--build","${workspaceRoot}\\build"],
21+
"isBuildCommand": true,
22+
"problemMatcher": {
23+
"owner": "cpp",
24+
"fileLocation": "absolute",
25+
"pattern": {
26+
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
27+
"file": 1,
28+
"line": 2,
29+
"column": 3,
30+
"severity": 4,
31+
"message": 5
32+
}
33+
}
34+
}
35+
]
36+
},
37+
"linux": {
38+
"command": "sh",
39+
"args": ["-c"],
40+
"tasks": [
41+
{
42+
"taskName": "clean",
43+
"args": [ "rm -rf", "${workspaceRoot}/build" ]
44+
},
45+
{
46+
"taskName": "cmake",
47+
"args": ["cmake", "--build","${cwd}"],
48+
"isBuildCommand": true
49+
}
50+
]
51+
}
52+
}

CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.0)
2+
project(Screen_Capture)
3+
4+
option(BUILD_EXAMPLE "Build example" On)
5+
6+
add_subdirectory(lib)
7+
8+
if(BUILD_EXAMPLE)
9+
add_subdirectory(Example)
10+
endif()

Example/CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
project(Screen_Capture_Example)
2+
3+
include_directories(${Screen_Capture_SOURCE_DIR}/include)
4+
5+
6+
add_executable(${PROJECT_NAME} tiny_jpeg.h Screen_Capture_Example.cpp)
7+
target_link_libraries(${PROJECT_NAME} Screen_Capturelib)
8+
9+
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)

Example/Screen_Capture_Example.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include "ScreenCaptureManager.h"
2+
#include <iostream>
3+
#include <chrono>
4+
#include <atomic>
5+
#include <thread>
6+
#include <string>
7+
#define TJE_IMPLEMENTATION
8+
#include "tiny_jpeg.h"
9+
10+
int main()
11+
{
12+
13+
std::atomic<int> realcounter;
14+
realcounter = 0;
15+
SL::Screen_Capture::ScreenCaptureManager framgrabber;
16+
SL::Screen_Capture::ImageCallback func = [&](const SL::Screen_Capture::CapturedImage& img) {
17+
std::cout << "Height " << img.Height << ", Width " << img.Width << ", Top " << img.AbsoluteTop << ", Left " << img.AbsoluteLeft << std::endl;
18+
auto r = realcounter.fetch_add(1);
19+
std::string s("screen");
20+
s += std::to_string(img.AbsoluteTop) + std::string(",") + std::to_string(img.AbsoluteLeft) +std::string(" ") + std::to_string(r) + std::string(".jpg");
21+
22+
if (!tje_encode_to_file(s.c_str(), img.Width, img.Height, 4, (const unsigned char*)img.Data.get())) {
23+
std::cout << "Could not write JPEG\n";
24+
}
25+
};
26+
framgrabber.StartCapturing(func, 100);
27+
28+
while (true) {
29+
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
30+
}
31+
32+
framgrabber.StopCapturing();
33+
int k = 0;
34+
std::cin >> k;
35+
return 0;
36+
}
37+

0 commit comments

Comments
 (0)