title: How to convert BufferedImage RGBA to BufferedImage RGB?
body: <p>So I tried looking for the solution but could not find a solution where I can convert the <code>RGBA</code> to <code>RGB</code> format.</p>
  
  <p>If a simple solution from BufferedImage to BufferedImage conversion is given then that will be best, otherwise the problem is as follows : </p>
  
  <p>Basically I have to convert BufferedImage into <code>MAT</code> format. It works properly for JPG/JPEG images but not PNGs. Following code I use for the conversion :: </p>
  
  <pre><code>BufferedImage biImg = ImageIO.read(new File(imgSource));
              mat = new Mat(biImg.getHeight(), biImg.getWidth(),CvType.CV_8UC3); 
              Imgproc.cvtColor(mat,matBGR, Imgproc.COLOR_RGBA2BGR);
              byte[] data = ((DataBufferByte) biImg.getRaster().getDataBuffer()).getData();
              matBGR.put(0, 0, data);
  </code></pre>
  
  <p>This throws error for images with RGBA values. So thus looking for a solution.</p>
  
  <p>Thanks in advance.</p>