Java Graphics.drawImage with different source color spaces and image types
<p>I'm trying to overlay a mostly-transparent PNG over a JPEG, and output the result as a JPEG file. I've attached my test input. Here's the code: (edit: FYI, this was translated into Java from Scala, not sure if I missed a syntax error or two, but you should get the idea from the code)</p>

<pre><code>BufferedImage img = new BufferedImage(800, 800, BufferedImage.TYPE_4BYTE_ABGR); //Goes to test.jpg
img.getGraphics.drawImage(source, 0, 0, Color.black, null); //source.jpg
img.getGraphics.drawImage(overlay, 0, 0, 400, 400, Color.black, null); //overlay.png

//First, get the final JPG into memory in a byte array (I use this elsewhere in my actual code)
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(img, "jpg", baos);
baos.flush();
byte[] bytes = baos.toByteArray();
baos.close();

FileUtils.writeByteArrayToFile(new File("test.jpg"), bytes);
</code></pre>

<p>Obviously, the output is not what I expected. What am I doing wrong here?
<img src="http://i.stack.imgur.com/iv4Vg.jpg" alt="source.jpg"><img src="http://i.stack.imgur.com/ZNVnJ.png" alt="overlay.png"><img src="http://i.stack.imgur.com/0yRge.jpg" alt="test.jpg"></p>
