How can I convert a byte array to a bitmap and stream the images through a web server?
<p>The project I am working on is capturing a frame from a security camera, with the help of <a href="http://en.wikipedia.org/wiki/Arduino" rel="nofollow">Arduino</a> UNO and <a href="http://nootropicdesign.com/ve/" rel="nofollow">Video Experimenter shield</a>. Then I am sending the frame as byte arrays through a serial port. I would like to ask, how could I, with Java, convert back this byte arrays to an image, and stream this image - or even make this images a video and then stream it - through a web server?</p>

<p>The code I have stacked with is this:</p>

<blockquote>
  <p>//Handle an event on the serial port. Read the data and save the image.</p>
  
  <p>public synchronized void serialEvent(SerialPortEvent oEvent) {</p>

<pre><code>   if (oEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE) {

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

       } catch (Exception e) {
           System.err.println(e.toString());
       } 
    }
</code></pre>
  
  <p>}</p>
</blockquote>

<p>That returns to my terminal window: java.lang.IllegalArgumentException: image == null!
continuously as long as arduino is sending data to the serial port.
Any suggestion?</p>
