Java examples for 2D Graphics:BufferedImage Resize
Image concatenated
//package com.java2s; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.*; public class Main { private static int rows = 2; private static int cols = 2; public static void knit(BufferedImage[] buffImages) throws IOException { int chunkWidth, chunkHeight; int type; type = buffImages[0].getType();//from w w w . j a v a2s . co m chunkWidth = buffImages[0].getWidth(); chunkHeight = buffImages[0].getHeight(); //Initializing the final image BufferedImage finalImg = new BufferedImage(chunkWidth * cols, chunkHeight * rows, type); int num = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { finalImg.createGraphics().drawImage(buffImages[num], chunkWidth * j, chunkHeight * i, null); num++; } } System.out.println("Image concatenated....."); ImageIO.write(finalImg, "jpeg", new File(System.getProperty("user.dir") + "/tmp/finalImg.jpg")); } }