public static BufferedImage concatenateImages ( final List < BufferedImage > imgCollection , final int width , final int height , final int imageType , final Direction concatenationDirection ) { final BufferedImage img = new BufferedImage ( width , height , imageType ) ; int x = 0 ; int y = 0 ; for ( final BufferedImage bi : imgCollection ) { final boolean imageDrawn = img . createGraphics ( ) . drawImage ( bi , x , y , null ) ; if ( ! imageDrawn ) { throw new RuntimeException ( "BufferedImage could not be drawn:" + bi . toString ( ) ) ; } if ( concatenationDirection . equals ( Direction . vertical ) ) { y += bi . getHeight ( ) ; } else { x += bi . getWidth ( ) ; } } return img ; }
Concatenate the given list of BufferedImage objects to one image and returns the concatenated BufferedImage object .