Java – Creates java.awt.Image from a byte array

Creates java.awt.Image from a byte array… here is a solution to the problem.

Creates java.awt.Image from a byte array

I am using the following code to convert a bitmap from an android device to a byte array and send it to a Java SE application via UDP, it works fine, my question is how to convert this byte array to java.awt.image.

Bitmap bmp = intent.getExtras().get("data");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();

In android I can do something similar

ImageView myImg = (ImageView) findViewById(;
myImg.setImageBitmap(BitmapFactory.decodeByteArray(bytSig, 0, bytSig.length))


Use this

Image image = ByteArrayInputStream(yourByteArray));

Related Problems and Solutions