Thumbnail from viewport

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DimitriyPS
:warning: Old Version Published before Godot 3 was released.

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?

:bust_in_silhouette: Reply From: Zylann

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(): Viewport — Godot Engine (latest) documentation in English

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).

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…

DimitriyPS | 2017-06-17 23:46