title: Java - Convert RAW to JPG/PNG
body: <p>I have an image captured by a camera, in RAW <code>BGRA</code> format (byte array).
  How can I save it to disk, as a <code>JPG/PNG</code> file?</p>
  
  <p>I've tried with <code>ImageIO.write</code> from Java API, but I got error IllegalArgumentException (image = null)</p>
  
  <p>CODE:</p>
  
  <pre><code>try
  {
      InputStream input = new ByteArrayInputStream(img);
      BufferedImage bImageFromConvert = ImageIO.read(input);
  
      String path = "D:/image.jpg";
  
      ImageIO.write(bImageFromConvert, "jpg", new File(path));
  }
  catch(Exception ex)
  {
      System.out.println(ex.toString());
  }
  </code></pre>
  
  <p>Note that "img" is the RAW byte array, and that is NOT null.</p>