|Topic was automatically imported from the old Question2Answer platform.
I am working on an editor image importer.
What I have is an Image object created from the file I try to import (in my importer import method). I can save it as a tres via a ImageTexture. But even if I call texture.set_storage to (lossless) compressed and use the compress flag on the ResourceSaver.save the tres is not compressed. It shows up in the editor, but the generated file is huge.
If I instead use the extension png and use image.save_png the generated file is a compressed PNG as expected, but unfortunately I get an error “No loader found for resource” and the texture does not show up in the editor.
ResourceSaver.get_recognized_extensions returns tres, tex, res, png. Trying to use the ResourceSaver to generate a tex, res, or png just results in the same “No loader found for resource” error. Only tres seem to be a valid choice to create something that is then actually loaded. Both the res and tex files generated are almost as small as the png though. The tres is about 75 times bigger, so not really something that can be used in practice.
For now I managed to work around this by looking at texture.cpp (and the generated stet-file for icon.png) and make my importer plugin generate a StreamTexture file (header plus PNG). It is a kludge, but it seems to work perfectly. Still would prefer to do it the right way if there is one.
lifelike | 2018-05-27 00:00
Here is the workaround if anyone needs it, but I have no idea how future-safe it is, just that it seems to work well for me in 3.0.6:
https://github.com/lifelike/godot-animator-import/blob/master/addons/aaimport/aa_import_plugin.gd (in the save_stex function).
lifelike | 2018-09-03 20:25