Here you can find the source of getBufferedImageMixedImages(BufferedImage image1, BufferedImage image2, int xImage2, int yImage2)
Parameter | Description |
---|---|
imageFormat | String.- png, jpg. |
image1 | BufferedImage |
image2 | BufferedImage |
xImage2 | int |
yImage2 | int |
Parameter | Description |
---|---|
IOException | an exception |
public static BufferedImage getBufferedImageMixedImages(BufferedImage image1, BufferedImage image2, int xImage2, int yImage2)
//package com.java2s; //License from project: Apache License import java.awt.Graphics; import java.awt.image.BufferedImage; public class Main { /**// ww w .j a v a 2 s . c o m * Mezcla dos imagenes en una sola, sobreponiendo la segunda en la primera. * @param imageFormat String.- png, jpg. * @param image1 BufferedImage * @param image2 BufferedImage * @param xImage2 int * @param yImage2 int * @return BufferedImage * @throws IOException */ public static BufferedImage getBufferedImageMixedImages(BufferedImage image1, BufferedImage image2, int xImage2, int yImage2) { // create the new image, canvas size is the max. of both image sizes int w = Math.max(image1.getWidth(), image2.getWidth()); int h = Math.max(image1.getHeight(), image2.getHeight()); BufferedImage mixedImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);//BufferedImage.TYPE_INT_ARGB); // paint both images, preserving the alpha channels Graphics g = mixedImage.getGraphics(); g.drawImage(image1, 0, 0, null); g.drawImage(image2, xImage2, yImage2, null); return mixedImage; } }