How to get Android to recognize images

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ondesic

I opened this issue LINK but haven’t heard anything. I have narrowed the problem down to the image itself. For some reason if I load an image with image.load() it will work great on the desktop, but not on android.

However, if I use the icon.png image that comes with Godot, my game will run fine on the Desktop and Android. The image I am testing has all the same properties as the icon.png, but Android doesn’t recognize it. I noticed that in the .import folder there are many more files associated with the icon.png image than my other pngs.

Could some one please help me figure out what is going on and how to make Godot on Android recognize images loaded with image.load()?

did you find any solution ?

igbow | 2020-12-02 19:01

:bust_in_silhouette: Reply From: ondesic

Yes, I found my own solution. Wish help was more available for Godot. This solution is in C#.

Image imgShape = new Image();

imgShape = LoadImage("res://YourDir/theImage.png");

public Image LoadImage(string path)//home brewed function
{
    Texture it = (Texture)GD.Load(path);
    return it.GetData();
}

Of course, put your actual path to the image instead of “YourDir”.