piegamesde / BlockMap

An out-of-game map renderer and viewer for Minecraft 1.13–1.18 worlds [unmaintained]
MIT License
92 stars 22 forks source link

Created a High-Res screenshot option to gui. #85

Open Igrium opened 1 year ago

Igrium commented 1 year ago

I was finding myself needing to easily take screen captures of my world at large scales, and due to my monitor's resolution, Snipping Tool wasn't cutting it. I decided to go ahead and code a simple function that takes a screenshot of the current viewport where one block = one pixel.

The feature can be accessed with File > Screenshot. It simply takes a screenshot there and then, and then brings up a file chooser so you can save it.

piegamesde commented 1 year ago

That's pretty cool, many thanks for doing this. I guess that it renders the world at the resolution of the screen/display, correct? Also, which parts of the overlay (grid, pins, etc.) get rendered)?

I think this is pretty similar to the request in #82, although for that the export should include the entire view and at full resolution. Maybe we can do both?

Igrium commented 1 year ago

This actually renders the world at a resolution where one block is equal to one pixel. So if you're viewing your world at 1:1, yes, that would be your display resolution. However, if you zoomed out and are viewing, say a 4K x 5K block area, your image would be 4000 pixels by 5000 pixels.

None of the UI elements get rendered because we're directly rendering the RenderedMap to a custom canvas and then saving it with Canvas#snapshot. The UI elements would need to be drawn to that canvas as well.

piegamesde commented 1 year ago

Code looks good to me except for one thing: If I zoom out a lot and then hit screenshot, the resulting image will be huge yet mostly contain transparent pixels. The rendered frustum should be clamped down to the bounds of the world to avoid this.

There is also the issue that – similarly to --create-big-image – this will easily require huge amounts of RAM. I'm willing to accept that, but maybe we should warn the users abouti t.

On a technical note, please target the PR against the develop branch.