ByteBuffer to a Image File

anyone know how to convert a ByteBuffer to a Image file



From the Kinect I have a 640 x 480 RGB ByteBuffer

An image is a ByteBuffer, you just have to order the bytes correctly or select the correct image format for that buffer.

Hi norman,

Can you explain further or point me at a good link.



Thanks,

Greg

Look at TestRenderToMemory, it does the opposite.

I see that textures have repeat

Texture tex = assetManager.loadTexture(key);

tex.setWrap(Texture.WrapMode.Repeat); // Tiles the Texture



and that material files have

MaterialParameters {

Tex1 : Flip Repeat Textures/Dice/Dice.tga

}





Is there a way to call Flip with java? something like tex.setFlip(true);???



Im using the kinect depth image to create my heightmap , but it seems to be flipped compared to the texture on the Terrain.

Yes, via material.getAdditionalRenderStates(), but thats not the setting you need, its a shader parameter.

Image newImage = new Image(Format.RGB8, 640, 480, byteBuffer);



or



Image newImage = new Image(Format.RGBA8, 640, 480, byteBuffer);

If you’re loading the data via AssetManager, pass the flipY flag to the TextureKey that you use to load the texture.

If you generate the data procedurally (e.g. Kinect), generate it with the bottom part first.