[SOLVED] How do I convert array of integer to Image? (For android)

Hello I would like to know if there was a class exactly like AWTLoader but for android?
Since AWT is not supported on Android I can’t use the BufferedImage and then convert the BufferedImage to Image and then use the Image in a Texture2D.

You could use the ImagePainter?Writer? from jme, it has a setPixel(x,y,ColorRGBA), maybee this is fast enough.

1 Like

I think you mean…
http://javadoc.jmonkeyengine.org/com/jme3/texture/image/ImageRaster.html

1 Like

I will give it a try thank you!

I’ve found ByteBuffer much faster in my case.

ByteBuffer buff = ByteBuffer.allocateDirect(width * height * 4);
for (int x = 0; x < width; x++) 
    for (int y = 0; y < height; y++) 
        buff.asIntBuffer().put(y * width + x, getVal(x, y));

Then you only build a new Image with that buffer.

new Image(Image.Format.RGBA8, width, height, buff)

Implementation here and here

1 Like

Thank you I finally got my game running on a cell phone :smile:

I m wondering is it possible to higher the terrain quality of the heightmap?
I use the lightingTerrain Material.

Could you be more specific? do hou need more samples for height nodes ? more smooth textures? Tell us more.

What i wanted to say is the Texture look so bad on android for the terrain! I can see my tree are still the same but the terrain texture is just bad, all pixeled.

I can’t show an exemple from before to after because of all the bug i got.
Lot s of AWT class need to be changed!

But over all I am happy of what i got and it s thank to you! :smiley: