mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-11-18 17:17:31 +00:00
Let capturer create output folder
This commit is contained in:
parent
4c6177676d
commit
5f3c55823c
@ -8,100 +8,101 @@ UsePNGImageEncoder()
|
|||||||
Declare Worker(*Dummy)
|
Declare Worker(*Dummy)
|
||||||
|
|
||||||
Structure QueueElement
|
Structure QueueElement
|
||||||
img.i
|
img.i
|
||||||
x.i
|
x.i
|
||||||
y.i
|
y.i
|
||||||
EndStructure
|
EndStructure
|
||||||
|
|
||||||
ProcedureDLL AttachProcess(Instance)
|
ProcedureDLL AttachProcess(Instance)
|
||||||
Global Semaphore = CreateSemaphore()
|
Global Semaphore = CreateSemaphore()
|
||||||
Global Mutex = CreateMutex()
|
Global Mutex = CreateMutex()
|
||||||
Global NewList Queue.QueueElement()
|
Global NewList Queue.QueueElement()
|
||||||
|
|
||||||
ExamineDesktops()
|
ExamineDesktops()
|
||||||
|
CreateDirectory("mods/noita-mapcap/output/")
|
||||||
|
|
||||||
For i = 1 To 4
|
For i = 1 To 4
|
||||||
CreateThread(@Worker(), #Null)
|
CreateThread(@Worker(), #Null)
|
||||||
Next
|
Next
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure Worker(*Dummy)
|
Procedure Worker(*Dummy)
|
||||||
Protected img, x, y
|
Protected img, x, y
|
||||||
|
|
||||||
Repeat
|
Repeat
|
||||||
WaitSemaphore(Semaphore)
|
WaitSemaphore(Semaphore)
|
||||||
|
|
||||||
LockMutex(Mutex)
|
LockMutex(Mutex)
|
||||||
FirstElement(Queue())
|
FirstElement(Queue())
|
||||||
img = Queue()\img
|
img = Queue()\img
|
||||||
x = Queue()\x
|
x = Queue()\x
|
||||||
y = Queue()\y
|
y = Queue()\y
|
||||||
DeleteElement(Queue())
|
DeleteElement(Queue())
|
||||||
UnlockMutex(Mutex)
|
UnlockMutex(Mutex)
|
||||||
|
|
||||||
SaveImage(img, "mods/noita-mapcap/output/" + x + "," + y + ".png", #PB_ImagePlugin_PNG)
|
SaveImage(img, "mods/noita-mapcap/output/" + x + "," + y + ".png", #PB_ImagePlugin_PNG)
|
||||||
FreeImage(img)
|
FreeImage(img)
|
||||||
ForEver
|
ForEver
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
ProcedureDLL Capture(px.i, py.i)
|
ProcedureDLL Capture(px.i, py.i)
|
||||||
; Get dimensions of main screen
|
; Get dimensions of main screen
|
||||||
|
|
||||||
x = DesktopX(0)
|
x = DesktopX(0)
|
||||||
y = DesktopY(0)
|
y = DesktopY(0)
|
||||||
w = DesktopWidth(0)
|
w = DesktopWidth(0)
|
||||||
h = DesktopHeight(0)
|
h = DesktopHeight(0)
|
||||||
|
|
||||||
imageID = CreateImage(#PB_Any, w, h)
|
imageID = CreateImage(#PB_Any, w, h)
|
||||||
If Not imageID
|
If Not imageID
|
||||||
ProcedureReturn
|
ProcedureReturn
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
; Get DC of whole screen
|
; Get DC of whole screen
|
||||||
screenDC = GetDC_(#Null)
|
screenDC = GetDC_(#Null)
|
||||||
If Not screenDC
|
If Not screenDC
|
||||||
FreeImage(imageID)
|
FreeImage(imageID)
|
||||||
ProcedureReturn
|
ProcedureReturn
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
hDC = StartDrawing(ImageOutput(imageID))
|
hDC = StartDrawing(ImageOutput(imageID))
|
||||||
If Not hDC
|
If Not hDC
|
||||||
FreeImage(imageID)
|
FreeImage(imageID)
|
||||||
ReleaseDC_(#Null, screenDC)
|
ReleaseDC_(#Null, screenDC)
|
||||||
ProcedureReturn
|
ProcedureReturn
|
||||||
EndIf
|
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.
|
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)
|
FreeImage(imageID)
|
||||||
ReleaseDC_(#Null, screenDC)
|
ReleaseDC_(#Null, screenDC)
|
||||||
StopDrawing()
|
StopDrawing()
|
||||||
ProcedureReturn
|
ProcedureReturn
|
||||||
EndIf
|
EndIf
|
||||||
StopDrawing()
|
StopDrawing()
|
||||||
|
|
||||||
ReleaseDC_(#Null, screenDC)
|
ReleaseDC_(#Null, screenDC)
|
||||||
|
|
||||||
LockMutex(Mutex)
|
LockMutex(Mutex)
|
||||||
; Check if the queue has too many elements, if so, wait. (Simulate go's channels)
|
; Check if the queue has too many elements, if so, wait. (Simulate go's channels)
|
||||||
While ListSize(Queue()) > 0
|
While ListSize(Queue()) > 0
|
||||||
UnlockMutex(Mutex)
|
UnlockMutex(Mutex)
|
||||||
Delay(10)
|
Delay(10)
|
||||||
LockMutex(Mutex)
|
LockMutex(Mutex)
|
||||||
Wend
|
Wend
|
||||||
LastElement(Queue())
|
LastElement(Queue())
|
||||||
AddElement(Queue())
|
AddElement(Queue())
|
||||||
Queue()\img = imageID
|
Queue()\img = imageID
|
||||||
Queue()\x = px
|
Queue()\x = px
|
||||||
Queue()\y = py
|
Queue()\y = py
|
||||||
UnlockMutex(Mutex)
|
UnlockMutex(Mutex)
|
||||||
|
|
||||||
SignalSemaphore(Semaphore)
|
SignalSemaphore(Semaphore)
|
||||||
|
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
; IDE Options = PureBasic 5.71 LTS (Windows - x64)
|
; IDE Options = PureBasic 5.71 LTS (Windows - x64)
|
||||||
; ExecutableFormat = Shared dll
|
; ExecutableFormat = Shared dll
|
||||||
; CursorPosition = 72
|
; CursorPosition = 25
|
||||||
; FirstLine = 32
|
; FirstLine = 3
|
||||||
; Folding = -
|
; Folding = -
|
||||||
; EnableThread
|
; EnableThread
|
||||||
; EnableXP
|
; EnableXP
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user