The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+1 vote

I have a painting game, I want to save the player's painting/viewport as a png.
Here's my code:

func save_painting():
    var masterpiece = get_viewport().get_texture().get_data()


    var save_path = "res://Minigames/paint/input/Masterpiece.png"


But I keep getting this error log:

ERROR: Can't save PNG at path: 'res://Minigames/paint/input/Masterpiece.png'. at: save_image (drivers/png/resource_saver_png.cpp:56) - Condition "err" is true. Returned: err

It works ok in Godot but once exported it causes a crash. Tried for days to solve this myself to no avail. Please help!

Thank you!

Godot version 3.3
in Engine by (34 points)

Do you have write permission to said location? Try running the exported game as administrator and see if that makes any difference.

1 Answer

0 votes

"res" folder only exists for a project. You need custom folder after exporting, the one that every user has. Usually it is user/appdata, but You can pick any real system path

by (8,188 points)

Thank you, I saved it at path user://masterpiece.png. It saves, and appears in the file manager, but when I try to load it as sprite texture in godot it gives this error message:

ERROR: Resource file not found: user://masterpiece.png.
   at: _load (core/io/resource_loader.cpp:275) - Condition "!file_check->file_exists(p_path)" is true. Returned: RES()

This is how i load it in godot:

$Sprite.texture = load("user://masterpiece.png")

Wracked my brain for days. Still confused.

Might you know why this error appears?

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 Frequently asked questions and 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 [email protected] with your username.