title: Java ARGB to JPG
body: <p>How can I save <em>BufferedImage</em> with <em>TYPE_INT_ARGB</em> to jpg?</p>
  
  <p>Program generates me that image:</p>
  
  <p><img src="https://i.stack.imgur.com/G1a4q.png" alt="enter image description here"></p>
  
  <p>And it's OK, but when I save it in that way:</p>
  
  <pre><code>    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
      BufferedOutputStream bos = new BufferedOutputStream(byteStream);
      try {
          ImageIO.write(buffImg, "jpg", bos);
          // argb
          byteStream.flush();
          byte[] newImage = byteStream.toByteArray();
  
          OutputStream out = new BufferedOutputStream(new FileOutputStream("D:\\test.jpg"));
          out.write(newImage);
          out.close();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  </code></pre>
  
  <p>The result is:
  <img src="https://i.stack.imgur.com/Whfjx.jpg" alt="enter image description here"></p>
  
  <p>Understand that this is due to the alpha layer, but don't know how to fix it. Png format does not suit me, need jpg.</p>