Java Graphics.drawImage with different source color spaces and image types -
i'm trying overlay mostly-transparent png on jpeg, , output result jpeg file. i've attached test input. here's code: (edit: fyi, translated java scala, not sure if missed syntax error or two, should idea code)
bufferedimage img = new bufferedimage(800, 800, bufferedimage.type_4byte_abgr); //goes 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, final jpg memory in byte array (i use elsewhere in 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);
obviously, output not expected. doing wrong here?
Comments
Post a Comment