0 votes

So, making a portrait maker. User can choose between different hair, eyes, clothing, etc options. It shows up just fine in the project as a bunch of TextureRects. However, I have no clue how to save the image. I've scaled down the textures to fit on screen so I can't just capture the viewport. Previously, I just created a new Image and then replaced all pixels that weren't transparent with the pixel from the TextureRects in succession. But that was for pixel art. If I did that with the resolution of the portraits I'm going to use for this one, I would have to iterate over 8 million times per image.

What should I do to export the images from this portrait maker? Should I use something besides Godot? If so, what?

Godot version 3.2.3
in Engine by (7,190 points)

I decided to just run the code anyway and it took 1.7 seconds to save an image. I guess that's acceptable. Maybe I'll put up a loading animation. Still wonder if there's a better way to do this.

1 Answer

0 votes

You can take a full screenshot like that :
var img:Image = get_viewport().get_texture().get_data()
var texture := ImageTexture.new()

by (2,478 points)

I've scaled down the textures to fit on screen so I can't just capture the viewport.

Plus, I want a transparent background and taking a screenshot wouldn't give me one.

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.