Screenshot Larger Than Window with Client Gametest Api
solonovamax opened this issue ยท 6 comments
When taking a screenshot larger that the current window size while an inventory open, then the opened inventory will only take up the size of the actual window in the top-right corner and the rest of the screenshot will be from the game outside of the opened inventory.
Further, the player's hand is not positioned properly, and is instead only below the far right edge of the opened inventory.
Here is a screenshot to demonstrate this:
The code for taking the screenshot looks roughly something like this:
// note: window was previously made fullscreen,
// and this is being performed on a device with a 1080p display
context.input.pressMouse(1) // open crafting table
context.waitFor { client -> client.currentScreen is CraftingScreen }
val screenshotOptions = TestScreenshotOptions.of(name)
.disableCounterPrefix()
.withSize(1920*4, 1080*4)
context.takeScreenshot(screenshotOptions)What do you observe to happen if you try? The game's framebuffer is supposed to resize regardless and this is what's used for screenshots. The visual window may be smaller than the game's framebuffer and the game's framebuffer will be stretched/shrunk to fit, but the visual window only exists for the user's benefit.
hmm, it may actually be capturing the proper resolution, then. I'd have to go back and check.
We might have to scrap this API, it doesn't seem to work too well. You can still make custom sizes by resizing the window and cropping in the case of comparisons
You can still make custom sizes by resizing the window and cropping in the case of comparisons
You cannot resize the window to be larger than your current device screen size (across multiple monitors. ie if you have 2 1080p monitors side-by-side, then your effective maximum width is actually 2160 pixels rather than just 1080 pixels) (this was tested on X11, unsure if the same thing applies to wayland/windows/macos).
We might have to scrap this API, it doesn't seem to work too well
I would like if you did not remove this api as I personally have found it to be extremely useful (albeit not necessarily for the intended purpose, however I do plan to use it for its intended purpose in other mods, now that I know about it)
I think the fix for this might be to force a full frame render before the screen shot, similar to what MinecraftClient#takeHugeScreenshot does (afaik) (unsure if you're doing this or not, but if not then give it a try)
You cannot resize the window to be larger than your current device screen size (across multiple monitors. ie if you have 2 1080p monitors side-by-side, then your effective maximum width is actually 2160 pixels rather than just 1080 pixels) (this was tested on X11, unsure if the same thing applies to wayland/windows/macos).
What do you observe to happen if you try? The game's framebuffer is supposed to resize regardless and this is what's used for screenshots. The visual window may be smaller than the game's framebuffer and the game's framebuffer will be stretched/shrunk to fit, but the visual window only exists for the user's benefit.
hmm, it may actually be capturing the proper resolution, then. I'd have to go back and check.
wait actually, wtf am I saying
obviously it does work and allow capturing images larger than the current window, otherwise how else would I have captured that example image lol (bc the example image is in 4k, however the device it was taken on is only has a 1080p screen)
