How can I convert a byte array to a bitmap and pass the images through a web server?

The project I'm working on is capturing a frame from a security camera using an Arduino UNO and a Video Experimenter Screen . Then I send the frame as byte arrays over the serial port. I would like to ask, how could I, using Java, convert these byte arrays to an image and transfer this image - or even make this image a video and then transfer it through a web server?

The code I laid down is this:

//Handle an event on the serial port. Read the data and save the image.

public synchronized void serialEvent(SerialPortEvent oEvent) {

    if (oEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE) {

        try {
            System.out.println("Got it!");
            int available = input.available();
            byte[] chunk = new byte[available];
  , 0, available);
            InputStream in = new ByteArrayInputStream(chunk);
            BufferedImage image =;
            ImageIO.write(image, "BMP", new File ("/home/zuss/images/image.BMP"));

        } catch (Exception e) {


This goes back to my terminal window: java.lang.IllegalArgumentException: image == null!

continuously while arduino is sending data to the serial port.


source to share

All Articles