How to add one image onto another in java

image, java

Solution

Create a `BufferedImage` with desired size. Use `getGraphics()` of the image and paint the first image and then the second one. `Graphics` has the method

public abstract boolean drawImage(Image img, int x, int y, 
                      Color bgcolor,
                      ImageObserver observer)

Problem

I have an image with a plain background. Now I need to place another image onto it at (x, y) location. How is it possible?

Original source