-
Notifications
You must be signed in to change notification settings - Fork 299
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
feat: high resolution screenshot from viewer #646
base: master
Are you sure you want to change the base?
feat: high resolution screenshot from viewer #646
Conversation
no functional changes though
…anel and layer resolution metadata
Overall this is great. One issue I noticed is that before you click "Take screenshot", you are essentially "previewing" the screenshot, but "Keep slice FOV fixed with scale change" has strange behavior. In particular, when "keep FOV" is checked and you increase from 1x to 2x, the preview FOV decreases by 2x; when "keep FOV" is unchecked, changing from 1x to 2x has no effect on the preview FOV. It would be better if the preview matched the FOV of the actual screenshot. |
…r if trying to close during screenshot.
Good point, thanks! The reason they behave like this is to try and give more accurate stats in the panel resolution preview and the layer resolution preview. But it's definitely true that this has the unfortunate side effect of visually giving the user the impression that these settings do the exact opposite in the preview than those settings will do in the actual screenshot. Example:From here. x1 resolution stats
x4 resolution stats, but the FOV will shrink in the screenshot (keep FOV unchecked)
x4 resolution stats, but the FOV will stay the same despite the increase in pixels (keep FOV checked)
Options for improving thisChange the pixels in the canvasThe best option that comes to mind is to actually change the number of pixels in the canvas while the user is interacting with the screenshot. At the moment this is avoided until the screenshot is initiated. This is because, for example picking an x4 resolution could result in a high burden on the user. It's possible though that will be ok. And if it causes issues, that could be overcome with a "confirm setting the resolution higher than the recommended 4k x 4k" This would also have the added benefit that we could start downloading the required data for an x4 screenshot while in the preview. Previously this data outside of the viewport would start downloading when the screenshot was initiated not during preview. I've just added a commit that makes this change. Please let me know what you think, and very open to other suggestions or further improvements. Can also do some further testing to see if the canvas pixel change causes issues for users during the preview. Screencast.from.2024-11-20.12-18-24.mp4 |
Thanks --- I think changing the canvas size while the user is configuring the settings is okay --- after all it will be happening anyway when the screenshot is actually generated. I noticed strange behavior when I choose 4x --- it looks like from your screencast that it doesn't happen for you, though. See video below. cast.webm |
Ah good spot, thank you. Turns out we didn't have enough pixels on the screen to come across this I set a higher resolution in dev-tools (see screenshot) and I can replicate the problem when I do that. I'll look into what might be causing the problem over a certain pixel threshold, but very open to thoughts if any come to mind on this. |
I dove into the code and I couldn't find anything wrong with the calculations around the canvas size in the display context or on the screenshot side. The only thing I could guess is that this is a side effect of the warning message that screenshots could fail if they became too large. I just pushed a commit that hard caps the scale factor to remain within these limits. The exact value cap is 5100 x 5100 pixels. This number is a little bit uncertain, but the screenshot seems to work well coming from a 1920 x 1080 monitor. Such a monitor resolution is fairly common, so seemed a decent base point. A 1920x1080 monitor tends to have about a 1850 x 878 px rendered area in neuroglancer, taking into account borders around viewport canvases and the top bar in neuroglancer etc. The square root of 1850 x 878 * 16 (for x4 scaling in the screenshot menu) is 5097. So a value of 5100 x 5100 should mean that the cap is never hit on a 1920 x 1080 monitor. While bigger monitors may hit the cap depending on their exact setup in neuroglancer. If this value needs further tuning it is just one constant to change and it would get passed through from that. |
x1, x2, and x4 screenshot functionality in the neuroglancer webviewer
Overall idea of files/classes:
ScreenshotHandler
is what actually interacts with the data to try and grab screenshot data, and repeatedly grab statistics while this is loading.ScreenshotManager
interacts with the display context to start theScreenshotHandler
process. It also receives information from theScreenshotHandler
and passes this on to the screenshot UI menu when appropriate. It saves the file when complete, and stops screenshots automatically if they hang.ScreenshotDialog
handles the user input to trigger actions in theScreenshotManager
, and shows updates from theScreenshotManager
to the user.