for my current work, I need to add images on top of other images at runtime. I already searched and I don't want to draw it on a Swing component, I use it in an external API.
Ideally, I would like a library (or a java-native way) with which I can specify several images to "layer", and it would return me a BufferedImage
(or any Image object by the way).
Asked
Active
Viewed 290 times
0

DanielBarbarian
- 5,093
- 12
- 35
- 44

Reymmer
- 43
- 3
-
If you want a single image (`BufferedImage`) in return, then you need to **compose** your images. Or what do you mean by "on top"? – Jean-Baptiste Yunès Aug 22 '16 at 19:00
-
I mean, I'd like to have an image which is on top of the background image (like a photoshop layer, if you see what you mean), and using something I'd like to have an Image object which is the background image with the other image on top. – Reymmer Aug 22 '16 at 19:20
-
This may help you http://stackoverflow.com/questions/2318020/merging-two-images – Jean-Baptiste Yunès Aug 22 '16 at 19:22
-
Thanks, works very well. Can I specify a position at which the image will the top image will be drawn, or have I to use same image sizes and transparency (like a mask) ? – Reymmer Aug 22 '16 at 19:38
-
Have a look at the documentation for method drawimage... – Jean-Baptiste Yunès Aug 22 '16 at 19:42
-
Oh ! I didn't even notice the x;y coordinates. You may add an answer so I can set the subjet to solved. – Reymmer Aug 22 '16 at 19:47
1 Answers
0
If you want a single image (BufferedImage
) in return, then you need to compose your images.
This answer may help you stackoverflow.com/questions/2318020/merging-two-images.
Have a look at the documentation for method drawImage
to control position and scaling of any drawing through the Graphics
object.

Jean-Baptiste Yunès
- 34,548
- 4
- 48
- 69