diff --git a/bin/capture-b/.gitignore b/bin/capture-b/.gitignore new file mode 100644 index 0000000..984791f --- /dev/null +++ b/bin/capture-b/.gitignore @@ -0,0 +1 @@ +!*.dll diff --git a/bin/capture-b/Capture.pb b/bin/capture-b/Capture.pb index 584f997..4af12a5 100644 --- a/bin/capture-b/Capture.pb +++ b/bin/capture-b/Capture.pb @@ -17,6 +17,8 @@ ProcedureDLL AttachProcess(Instance) Global Semaphore = CreateSemaphore() Global Mutex = CreateMutex() Global NewList Queue.QueueElement() + + ExamineDesktops() For i = 1 To 4 CreateThread(@Worker(), #Null) @@ -44,9 +46,7 @@ EndProcedure ProcedureDLL Capture(px.i, py.i) ; Get dimensions of main screen - - ExamineDesktops() - + x = DesktopX(0) y = DesktopY(0) w = DesktopWidth(0) @@ -59,14 +59,23 @@ ProcedureDLL Capture(px.i, py.i) ; Get DC of whole screen screenDC = GetDC_(#Null) - - hDC = StartDrawing(ImageOutput(imageID)) - If Not hDC - ReleaseDC_(#Null, screenDC) + If Not screenDC FreeImage(imageID) ProcedureReturn EndIf - BitBlt_(hDC, 0, 0, w, h, screenDC, x, y, #SRCCOPY) + + hDC = StartDrawing(ImageOutput(imageID)) + If Not hDC + FreeImage(imageID) + ReleaseDC_(#Null, screenDC) + ProcedureReturn + EndIf + If Not BitBlt_(hDC, 0, 0, w, h, screenDC, x, y, #SRCCOPY) ; After some time BitBlt will fail, no idea why. Also, that's moments before noita crashes. + FreeImage(imageID) + ReleaseDC_(#Null, screenDC) + StopDrawing() + ProcedureReturn + EndIf StopDrawing() ReleaseDC_(#Null, screenDC) @@ -91,7 +100,8 @@ EndProcedure ; IDE Options = PureBasic 5.71 LTS (Windows - x64) ; ExecutableFormat = Shared dll -; CursorPosition = 15 +; CursorPosition = 72 +; FirstLine = 32 ; Folding = - ; EnableThread ; EnableXP diff --git a/bin/capture-b/README.md b/bin/capture-b/README.md index bb20648..98b5325 100644 --- a/bin/capture-b/README.md +++ b/bin/capture-b/README.md @@ -4,4 +4,4 @@ A dynamically linked library, that supplies a single function to take a screensh ## State -Works, not as fast as the go version, but ok. +Works, not as fast as the go version, but fast enough. diff --git a/bin/capture-b/capture.dll b/bin/capture-b/capture.dll new file mode 100644 index 0000000..fb4eb27 Binary files /dev/null and b/bin/capture-b/capture.dll differ