Attaching JFIF jpg picture to quad

Hi all,

i’m pulling an image off a mjpeg stream to a game server then shipping the image bytes out to my gaming client in 2 messages. i’m able to re assemble the bytes into a byte buffer but i’m riding the struggle bus on getting the image to show up in game. I think im getting reall close since i get a bunch of pixels that flicker about.

when i set:

[java]gameClient.getWebcamViewerAppState().getImageTexture().setImage(new Image(jmeformat,640,480, readBuffer.duplicate()));[/java]

to 640, 480 i get :

and when i set it to

[java]gameClient.getWebcamViewerAppState().getImageTexture().setImage(new Image(jmeformat,100,100, readBuffer.duplicate()));[/java]

100x100 i get:

Here is the full code:


public class ClientListener implements MessageListener<Client>{

private GameClient gameClient;

private ByteBuffer readBuffer;

private int currentImage = 0;

final public Format jmeformat = Format.RGBA8;

public ClientListener(GameClient gameClient){

this.gameClient = gameClient;

readBuffer = ByteBuffer.allocateDirect((6404804));


public void messageReceived(Client source, Message message) {

if(message instanceof WebcamMessage){

WebcamMessage webcamMessage = (WebcamMessage) message;

if(webcamMessage.getPart() == 0){


currentImage = webcamMessage.getImageNumber();

}else if(webcamMessage.getPart() == 1 && currentImage == webcamMessage.getImageNumber()){


if(gameClient.getWebcamViewerAppState().getImageTexture() != null)

gameClient.getWebcamViewerAppState().getImageTexture().setImage(new Image(jmeformat,100,100, readBuffer.duplicate()));







I’m kind of punting here and guessing the correct jme Format, the image is supposed to be 640x480. Any insight would be helpfull.

Thanks in advance


If the image is in JPEG format, then you need to decode it first. jME3 only expects uncompressed image data