Here you can find the source of knit(BufferedImage[] buffImages)
public static void knit(BufferedImage[] buffImages) throws IOException
//package com.java2s; //License from project: Open Source License 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 a2 s. c o 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")); } }