How to load android.Image jpeg data as Texture2d RGBA format?

I’m trying to load phone cam stream as a texture for a Quad geometry.
Right now , I have to save the android.image to a jpeg file then use assetManager to load it.
or set the Image format as Pixel.rgba888 then I have no difficulty to copy data buffer to a JME texture2D.
Problem for me is, only jpeg format is guaranteed for all android phones.

Is there a way to just transfer the Android.Image jpeg buffer data into a rgba format data ?

Have you tried using ByteBuffer Image.Plane#getBuffer() to retrieve the direct byte buffer?

I think this is then what you need after retrieving the direct buffer, it should be fitted here to transfer the data to a JME image:

1 Like

Yes, I did.
Problem is : the data in the direct buffer is in Android.ImageFormat.jpeg format and I’d like to transform it into Jme.Image formats like: RGBA8888.

Regarding your query, converting Android.Image jpeg buffer data into RGBA format might require some custom processing. You could explore libraries or APIs that specialize in image manipulation to facilitate this conversion seamlessly. It might involve decoding the JPEG data and then re-encoding it into the desired RGBA format.

1 Like