Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screenshot Larger Than Window with Client Gametest Api #4411

Open
solonovamax opened this issue Feb 1, 2025 · 6 comments
Open

Screenshot Larger Than Window with Client Gametest Api #4411

solonovamax opened this issue Feb 1, 2025 · 6 comments

Comments

@solonovamax
Copy link

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:

Image

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)
@Earthcomputer
Copy link
Contributor

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

@solonovamax
Copy link
Author

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)

@solonovamax
Copy link
Author

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)

@Earthcomputer
Copy link
Contributor

Earthcomputer commented Feb 3, 2025

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.

@solonovamax
Copy link
Author

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.

@solonovamax
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants