0 votes

I need to create a thumbnail of a specified size from viewport to save game. How to create thumbnail? As a thumbnail, save it to disk?

in Engine by (354 points)

1 Answer

+1 vote
Best answer

The Viewport class has a queue_screen_capture() function. You can get the viewport with get_tree().get_root().

I never used it yet, but according to documentation you have to call queue_screen_capture(), which will start an asynchronous screen capture. Then, several frames later, you get the screenshot with get_screen_capture(): http://docs.godotengine.org/en/latest/classes/class_viewport.html?highlight=queue_screen_capture#class-viewport-queue-screen-capture

You can poll for that image in _process() I guess. Then if the image is too big, you can resize it with var thumbnail = captured_image.resized(width, height).

by (27,825 points)
selected by

I've long not solved this problem. Now I did it. Thank you very much.

I hope it will not be revised in Godot 3.0...

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.