-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from ludos1978/ReworkingCmakeBuild
Reworkingcmakebuild
- Loading branch information
Showing
42 changed files
with
889 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
project(screen_capture_lite_example_csharp) | ||
|
||
set(OUTPUT ${PROJECT_NAME}.dll) | ||
set(CSPROJ ${PROJECT_NAME}.csproj) | ||
|
||
execute_process(COMMAND dotnet --version | ||
RESULT_VARIABLE result | ||
OUTPUT_QUIET | ||
ERROR_QUIET) | ||
if(result) | ||
message(WARNING "CMake failed: dotnet executable not found but by this build. You must install dotnet to generate csharp bindings") | ||
else() | ||
message(STATUS "Found dotnet executable CSHARP bindings will be generated!") | ||
add_custom_command(OUTPUT ${OUTPUT} | ||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:screen_capture_lite_shared> ${CMAKE_CURRENT_LIST_DIR} | ||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:screen_capture_lite_shared> ${CMAKE_BINARY_DIR}/Example_CSharp | ||
COMMAND ${CMAKE_COMMAND} -E copy | ||
${CMAKE_CURRENT_LIST_DIR}/${CSPROJ} | ||
${CMAKE_BINARY_DIR}/Example_CSharp | ||
COMMAND ${CMAKE_COMMAND} -E copy | ||
${CMAKE_CURRENT_LIST_DIR}/Program.cs | ||
${CMAKE_BINARY_DIR}/Example_CSharp | ||
COMMAND dotnet build --configuration ${CMAKE_BUILD_TYPE} ${CMAKE_BINARY_DIR}/Example_CSharp/${CSPROJ} -o ${CMAKE_BINARY_DIR} | ||
COMMENT "Building DOTNET Example ${CMAKE_BINARY_DIR}/${OUTPUT}" | ||
) | ||
add_custom_target(${PROJECT_NAME} ALL DEPENDS ${OUTPUT}) | ||
add_dependencies(${PROJECT_NAME} screen_capture_lite_csharp) | ||
|
||
install (FILES ${CMAKE_BINARY_DIR}/${OUTPUT} | ||
DESTINATION bin | ||
) | ||
install (FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb | ||
DESTINATION bin | ||
OPTIONAL | ||
) | ||
|
||
install (TARGETS screen_capture_lite_shared | ||
RUNTIME DESTINATION Examples | ||
) | ||
|
||
endif() | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Drawing; | ||
using System.Threading; | ||
|
||
namespace screen_capture_lite_example_csharp | ||
{ | ||
public class Program | ||
{ | ||
private static void WriteLine(ref SL.Screen_Capture.Monitor p) | ||
{ | ||
Console.WriteLine($"Id = {p.Id} Index = {p.Index} Height = {p.Height} Width = {p.Width} OffsetX = {p.OffsetX} OffsetY= {p.OffsetY} Name= {p.Name}"); | ||
} | ||
private static void WriteLine(ref SL.Screen_Capture.Image p) | ||
{ | ||
Console.WriteLine($"BytesToNextRow = {p.BytesToNextRow} isContiguous = {p.isContiguous} Bounds.bottom = {p.Bounds.bottom} Bounds.left = {p.Bounds.left} Bounds.right = {p.Bounds.right} Bounds.top = {p.Bounds.top}"); | ||
} | ||
static int onNewFramecounter = 0; | ||
static DateTime onNewFramestart = DateTime.Now; | ||
public static SL.Screen_Capture.CaptureConfiguration.ScreenCaptureManager createframegrabber() | ||
{ | ||
onNewFramecounter = 0; | ||
onNewFramestart = DateTime.Now; | ||
return SL.Screen_Capture.CaptureConfiguration.CreateCaptureConfiguration(() => | ||
{ | ||
var mons = SL.Screen_Capture.GetMonitors(); | ||
Console.WriteLine("Library is requesting the list of monitors to capture!"); | ||
for (int i = 0; i < mons.Length; ++i) | ||
{ | ||
WriteLine(ref mons[i]); | ||
} | ||
return mons; | ||
}).onNewFrame((ref SL.Screen_Capture.Image img, ref SL.Screen_Capture.Monitor monitor) => | ||
{ | ||
//var newBitmap = new Bitmap(img.Bounds.right - img.Bounds.left, img.Bounds.bottom - img.Bounds.top, img.BytesToNextRow, System.Drawing.Imaging.PixelFormat.Format32bppRgb, img.Data); | ||
//newBitmap.Save($"{onNewFramecounter++}onNewFrame.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); | ||
//WriteLine(ref img); | ||
//WriteLine(ref monitor); | ||
if ((DateTime.Now - onNewFramestart).TotalMilliseconds > 1000) | ||
{ | ||
Console.WriteLine("onNewFrame fps" + onNewFramecounter); | ||
onNewFramestart = DateTime.Now; | ||
onNewFramecounter = 0; | ||
} | ||
Interlocked.Increment(ref onNewFramecounter); | ||
|
||
}).onFrameChanged((ref SL.Screen_Capture.Image img, ref SL.Screen_Capture.Monitor monitor) => | ||
{ | ||
//var newBitmap = new Bitmap(img.Bounds.right - img.Bounds.left, img.Bounds.bottom - img.Bounds.top, img.BytesToNextRow, System.Drawing.Imaging.PixelFormat.Format32bppRgb, img.Data); | ||
//newBitmap.Save($"{onNewFramecounter++}onFrameChanged.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); | ||
//WriteLine(ref img); | ||
//WriteLine(ref monitor); | ||
}).start_capturing(); | ||
} | ||
|
||
public static void Main(string[] args) | ||
{ | ||
Console.WriteLine("Starting Capture Demo/Test"); | ||
var goodmonitors = SL.Screen_Capture.GetMonitors(); | ||
for (int i = 0; i < goodmonitors.Length; ++i) | ||
{ | ||
WriteLine(ref goodmonitors[i]); | ||
Debug.Assert(SL.Screen_Capture.isMonitorInsideBounds(goodmonitors, goodmonitors[i])); | ||
} | ||
|
||
var badmonitors = SL.Screen_Capture.GetMonitors(); | ||
for (int i = 0; i < badmonitors.Length; ++i) | ||
{ | ||
badmonitors[i].Height += 1; | ||
WriteLine(ref badmonitors[i]); | ||
Debug.Assert(!SL.Screen_Capture.isMonitorInsideBounds(goodmonitors, badmonitors[i])); | ||
} | ||
for (int i = 0; i < badmonitors.Length; ++i) | ||
{ | ||
badmonitors[i].Width += 1; | ||
WriteLine(ref badmonitors[i]); | ||
Debug.Assert(!SL.Screen_Capture.isMonitorInsideBounds(goodmonitors, badmonitors[i])); | ||
} | ||
|
||
Console.WriteLine("Running display capturing for 10 seconds"); | ||
using (var framgrabber = createframegrabber()) | ||
{ | ||
System.Threading.Thread.Sleep(10 * 1000); | ||
} | ||
|
||
Console.WriteLine("Running display capturing for 1 seconds"); | ||
using (var framgrabber = createframegrabber()) | ||
{ | ||
System.Threading.Thread.Sleep(1 * 1000); | ||
Console.WriteLine("Pausing for 10 seconds."); | ||
framgrabber.pause(); | ||
var counti = 0; | ||
while (counti++ < 10) | ||
{ | ||
Debug.Assert(framgrabber.isPaused()); | ||
Console.Write(" . "); | ||
System.Threading.Thread.Sleep(1 * 1000); | ||
} | ||
Console.WriteLine("Resuming . . . for 5 seconds"); | ||
framgrabber.resume(); | ||
System.Threading.Thread.Sleep(5 * 1000); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.