Com.jme3.texture.Image to java.awt.Image

I am currently in need of finding a subImage within the image of a texture in jME3, the only way I know how to do this is to get an Image, convert it to a BufferedImage, use getSubImage, then convert that back into an image, however I do not know how to get a java.awt.Image from a Texture variable, nor do I know how to create a Texture variable out of a java.awt.Image. I am assuming there must be an intermediary between java Images and jme3 images, can someone please tell me how to convert between the two? THank you!

in BeginnerTest10_Terain there is this code :

[java]final Texture heightMapImage = assetManager.loadTexture("Textures/Terrain/splat/mountains512.png");

final AbstractHeightMap heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0));


i guess ImageToAwt creates the image.

hope that helps

Wow how did I skip over that << it is part of my code lol. Thank you so much haha

Might sound like yet another silly question, but how can you make a Texture variable out of a BUfferedImage, the first step is to probably convert it back to a jme3 image using ImageToAwt.convert(BufferedImage, ImageFormat, ByteBuffer), however how do you take the image formed from that byteBuffer and make it a texture?

again i am guessing. Does Texture.setImage(); //work ?

setImage is supposed to work, but for some odd issues, that above method I proposed does not work, I fill the ByteBuffer, however the image created out of using Image.setData(ByteBuffer); just doesnt create the image. It keep throwing NullPointerExceptions. Here is my current code:

[java]BufferedImage tempImage = imgHandler.GetAlphaMapSubImage(y * subAlphaWidth, x * subAlphaHeight, subAlphaWidth, subAlphaHeight);

ByteBuffer test = ByteBuffer.allocate((4 * imgHandler.GetAlphaMapWidth()) * (4 * imgHandler.GetAlphaMapHeight()));

ImageToAwt.convert(tempImage, Format.Alpha8, test);

com.jme3.texture.Image result = new com.jme3.texture.Image();//(Format.Alpha8, imgHandler.GetAlphaMapWidth(), imgHandler.GetAlphaMapHeight(), test);


//result.addData(test) // Did not work either

Texture tex = assetManager.loadTexture(alphaPath);


return tex;[/java]