I've been trying to save an image to sdcard on Android. I tried so many ways.
I created a com.packagename.gamename directory inside /mnt/Android/data to save the image.
I know that GLES2 doesn't support reading back GPU and it won't work if I try get_texture().get_data().save_png
But I can create an image like this
var i = Image(100,100,false,Image.FORMAT_RGBA)
i.save_png(path)
And also I can save the screenshot image like this
get_viewport().queue_screen_capture()
yield(get_tree(),"idle_frame")
yield(get_tree(),"idle_frame")
get_viewport().get_screen_capture().save_png(path)
All the working things are Image type, but this doesn't work
var i = Image()
i.load("res://path_to_image.png")
i.save_png(path)
I've also tried reading the image file and copy to the destination directory using
var src = File.new()
src.open("source_path.png",File.READ)
var buffer = src.get_buffer(src.get_len()) #some error at get_len() on android
var dest = File.new()
dest.open("dest_path.png",File.WRITE)
dest.store_buffer(buffer)
dest.close()
This also does not work
var d = Directory.new()
d.copy("source_path.png","dest_path.png")
All the above things does work on PC but not on Android.
So, is there any other way to save an image to disk other than adding the image to scene and saving the screenshot?
(Why the screenshot image does save, while others not saving? Can I recreate the an image with "required image data" similar to the screenshot image?)