I have 2 BufferedImage
that I want to place one on top of the other(layers like), here is my code following combine-buffered-images:
private void combainImages(List<String> imageList, String combainedImages) throws IOException {
BufferedImage a = ImageIO.read(new File(imageList.get(0))); //imageList holds the path to all images
BufferedImage b = ImageIO.read(new File(imageList.get(1)));
BufferedImage c = new BufferedImage(a.getWidth(), a.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics g = c.getGraphics();
g.drawImage(a, 0, 0, null);
g.drawImage(b, 0, 0, null);
ImageIO.write(c, "PNG", new File(combainedImages));
}
The result is that the second image is draw on the first image not beneath, so in combainedImages
is same as the second picture.
Thanks for any help.