I have two ImageIcons and I want to create a third ImageIcon which has nr 2 drawn upon nr 1.
How would I best do that?
I have two ImageIcons and I want to create a third ImageIcon which has
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The following code takes an
Imagefrom twoImageIcons and creates a newImageIcon.The image from the second
ImageIconis drawn on top of the image from the first, then the resulting image is used to make a newImageIcon:Edit
(Fixed some errors, added transparency support.)
For allowing transparency, the
BufferedImage.TYPE_INT_ARGBcan be used for the image type in the constructor, rather thanBufferedImage.TYPE_INT_RGBwhich does not have an alpha channel.