Thank you Zylann, I managed to find a way because of your hint. You really saved my life. ^_^ It's something like the following:
GDscript:
func screen_capture():
......
#Retrieve the captured image and store in the member var img
img = get_viewport().get_screen_capture()
#call Java singleton to get path
JavaSingleton.askForPath()
func _on_call_back(path):
if path != "":
#save image to Android device path
img.save_png(path)
#call Java singleton to share the image
JavaSingleton.postToShare()
Java singleton:
public void askForPath() {
String fileName = "Screen.png";
String dirPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Screenshots";
File dir = new File(dirPath);
if(!dir.exists())
dir.mkdirs();
file = new File(dirPath, fileName);
GodotLib.calldeferred(instance_id, "_on_call_back", new Object[]{file.toString()});
}
public void postToShare(){
......
}
I know it's not elegant at all, but it gets my job done. It's not the best answer. I hope someday someone can give a smarter solution to pass the colors array directly instead of writing the file to disk as you said. Hope my answer can help someone who needs it. Thanks again! Zylann!