Update capture method

- Capture hWnd HDC directly (Window can be behind other windows)
- Update README.md
This commit is contained in:
David Vogel 2020-10-18 00:39:58 +02:00
parent 478a6262e8
commit c78a8b56ae
3 changed files with 31 additions and 27 deletions

View File

@ -1,14 +1,14 @@
# Noita MapCapture addon [![Build Status](https://travis-ci.com/Dadido3/noita-mapcap.svg?branch=master)](https://travis-ci.com/Dadido3/noita-mapcap)
Addon that captures the map and saves it as image.
Addon that captures a Noita world and saves it as image.
![missing image](images/example1.png)
A resulting image with 3.8 gigapixels can be [seen here](https://easyzoom.com/image/203402) (Warning: Spoilers).
A resulting image with nearly 3.8 gigapixels can be [seen here](https://easyzoom.com/image/223556) (Warning: Spoilers).
## System requirements
- Windows Vista, ..., 10. (64 bit version)
- Windows Vista, ..., 10. (64 bit OS for stitching)
- A few GB of free drive space.
- 4 or more GB of RAM for gigapixel images. (But it works with less as long as the software doesn't run out of virtual memory)
- A processor.
@ -28,11 +28,11 @@ A resulting image with 3.8 gigapixels can be [seen here](https://easyzoom.com/im
- Or press `>> Start capturing full map <<` to capture the whole map.
7. The screen will jump around, and the game will take screenshots automatically.
- Screenshots are saved in `.../Noita/mods/noita-mapcap/output/`.
- Don't cover the game window.
- Don't move the game window outside of screen space.
- Don't move the game window outside of screen space. You can cover it with other windows, and continue using your PC.
- Don't minimize the game window.
- If you need to pause, use the ESC menu.
- Also, make sure that the console window isn't selected, as you will end up with screenshots of the console instead of the game. You can select and use any other window while it's capturing screenshots, though.
8. When you think you are done, close noita.
8. When you think you are done, close Noita.
9. Start `.../Noita/mods/noita-mapcap/bin/stitch/stitch.exe`.
- Use the default values to create a complete stitch.
- It will take the screenshots from the `output` folder.
@ -50,8 +50,8 @@ Here is a step by step explanation how to do so:
``` xml
<MagicNumbers
VIRTUAL_RESOLUTION_X="840"
VIRTUAL_RESOLUTION_Y="840"
VIRTUAL_RESOLUTION_X="1024"
VIRTUAL_RESOLUTION_Y="1024"
...
>
```
@ -61,12 +61,12 @@ Here is a step by step explanation how to do so:
``` xml
<Config
...
backbuffer_height="840"
backbuffer_width="840"
internal_size_h="840"
internal_size_w="840"
window_h="840"
window_w="840"
backbuffer_height="1024"
backbuffer_width="1024"
internal_size_h="1024"
internal_size_w="1024"
window_h="1024"
window_w="1024"
fullscreen="0"
...
>
@ -75,7 +75,7 @@ Here is a step by step explanation how to do so:
If that file doesn't exist do step 5, and come back here, and continue from step 3.
4. Patch your `.../Noita/noita_dev.exe` with [Large Address Aware](https://www.techpowerup.com/forums/threads/large-address-aware.112556/) or a similar tool.
This is optional, but it prevents crashes from noita running out of memory.
This is optional, but it prevents crashes from Noita running out of memory.
5. Start `.../Noita/noita_dev.exe`.
@ -94,7 +94,7 @@ If you use `noita_dev.exe`, you can enable the debug mode by pressing `F5`. Once
You can capture in a different resolution if you want or need to. If you do so, you have to adjust some values inside of the mod.
The following two formulae have to be true:
The following two equations have to be true:
![CAPTURE_PIXEL_SIZE = SCREEN_RESOLUTION_* / VIRTUAL_RESOLUTION_*](https://latex.codecogs.com/png.latex?%5Cinline%20%5Cdpi%7B120%7D%20%5Clarge%20%5Cbegin%7Balign*%7D%20%5Ctext%7BCAPTURE%5C_PIXEL%5C_SIZE%7D%20%26%3D%20%5Cfrac%7B%5Ctext%7BSCREEN%5C_RESOLUTION%5C_X%7D%7D%7B%5Ctext%7BVIRTUAL%5C_RESOLUTION%5C_X%7D%7D%5C%5C%20%5Ctext%7BCAPTURE%5C_PIXEL%5C_SIZE%7D%20%26%3D%20%5Cfrac%7B%5Ctext%7BSCREEN%5C_RESOLUTION%5C_Y%7D%7D%7B%5Ctext%7BVIRTUAL%5C_RESOLUTION%5C_Y%7D%7D%20%5Cend%7Balign*%7D)

View File

@ -89,8 +89,12 @@ Procedure Worker(*Dummy)
EndProcedure
ProcedureDLL Capture(px.i, py.i)
Protected rect.RECT
Protected hWnd.l = GetProcHwnd()
If Not hWnd
ProcedureReturn #False
EndIf
Protected rect.RECT
If Not GetRect(@rect)
ProcedureReturn #False
EndIf
@ -101,27 +105,27 @@ ProcedureDLL Capture(px.i, py.i)
EndIf
; Get DC of whole screen
screenDC = GetDC_(#Null)
If Not screenDC
windowDC = GetDC_(hWnd)
If Not windowDC
FreeImage(imageID)
ProcedureReturn #False
EndIf
hDC = StartDrawing(ImageOutput(imageID))
If Not hDC
ReleaseDC_(hWnd, windowDC)
FreeImage(imageID)
ReleaseDC_(#Null, screenDC)
ProcedureReturn #False
EndIf
If Not BitBlt_(hDC, 0, 0, rect\right-rect\left, rect\bottom-rect\top, screenDC, rect\left, rect\top, #SRCCOPY) ; After some time BitBlt will fail, no idea why. Also, that's moments before noita crashes.
FreeImage(imageID)
ReleaseDC_(#Null, screenDC)
If Not BitBlt_(hDC, 0, 0, rect\right-rect\left, rect\bottom-rect\top, windowDC, 0, 0, #SRCCOPY) ; After some time BitBlt will fail, no idea why. Also, that's moments before noita crashes.
StopDrawing()
ReleaseDC_(hWnd, windowDC)
FreeImage(imageID)
ProcedureReturn #False
EndIf
StopDrawing()
ReleaseDC_(#Null, screenDC)
ReleaseDC_(hWnd, windowDC)
LockMutex(Mutex)
; Check if the queue has too many elements, if so, wait. (Simulate go's channels)
@ -149,10 +153,10 @@ EndProcedure
;Capture(123, 123)
;Delay(1000)
; IDE Options = PureBasic 5.71 LTS (Windows - x64)
; IDE Options = PureBasic 5.72 (Windows - x64)
; ExecutableFormat = Shared dll
; CursorPosition = 140
; FirstLine = 94
; CursorPosition = 90
; FirstLine = 77
; Folding = --
; EnableThread
; EnableXP

Binary file not shown.